diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-05-07 01:08:56 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-05-07 01:08:56 +0000 |
commit | a5d9cd1b43c034953ec3cd60331aba6b9591c417 (patch) | |
tree | e48f423ffe5e6f8b1f34b3c29510049fb7ec8469 /src | |
parent | 32792bb121ea2bb1a96eca821061a3a9b13a6a78 (diff) | |
download | PenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.tar.gz PenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.tar.bz2 PenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.zip |
Better setup for web build
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/gameCommon.h | 7 | ||||
-rw-r--r-- | src/main.c | 27 |
3 files changed, 24 insertions, 12 deletions
@@ -29,7 +29,7 @@ void initGame(Game* game) game->madeWithUnity = createAnimation(&game->assets.animations[MADE_WITH_UNITY_ANIMATION], 0.2); game->madeWithUnity.repeat = false; - //playAnimation(&game->madeWithUnity); + playAnimation(&game->madeWithUnity); } void updateGame(Game* game) diff --git a/src/gameCommon.h b/src/gameCommon.h index 1592092..78c17e4 100644 --- a/src/gameCommon.h +++ b/src/gameCommon.h @@ -7,10 +7,15 @@ #include <raylib.h> #include <raymath.h> +//#define PLATFORM_WEB + +#if defined(PLATFORM_WEB) + #include <emscripten/emscripten.h> +#endif + #define WINDOW_WIDTH 1280 #define WINDOW_HEIGHT 720 - // Memory management. #define YP_MALLOC(size) malloc(size) #define YP_CALLOC(nmemb, size) calloc(nmemb, size) @@ -1,17 +1,24 @@ #include "gameCommon.h" #include "game.h" -#include <raylib.h> -int main(int argc, char** argv) -{ - Game game; - initGame(&game); +Game game; - while (!WindowShouldClose()) - { - updateGame(&game); +void updateFrame() { + updateGame(&game); +} + +int main(int argc, char ** argv) { + initGame(&game); + +#ifdef PLATFORM_WEB + emscripten_set_main_loop(updateFrame, 0, 1); +#else + while (!WindowShouldClose()) { + updateFrame(); } +#endif - closeGame(&game); - return 0; + closeGame(&game); + return 0; } + |