From a5d9cd1b43c034953ec3cd60331aba6b9591c417 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Mon, 6 May 2024 19:08:56 -0600 Subject: Better setup for web build --- src/game.c | 2 +- src/gameCommon.h | 7 ++++++- src/main.c | 27 +++++++++++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/game.c b/src/game.c index 6f74c58..df8a57b 100644 --- a/src/game.c +++ b/src/game.c @@ -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 #include +//#define PLATFORM_WEB + +#if defined(PLATFORM_WEB) + #include +#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) diff --git a/src/main.c b/src/main.c index e2e5e67..6dd4a69 100644 --- a/src/main.c +++ b/src/main.c @@ -1,17 +1,24 @@ #include "gameCommon.h" #include "game.h" -#include -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; } + -- cgit v1.2.3