aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-05-07 01:08:56 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-05-07 01:08:56 +0000
commita5d9cd1b43c034953ec3cd60331aba6b9591c417 (patch)
treee48f423ffe5e6f8b1f34b3c29510049fb7ec8469 /src
parent32792bb121ea2bb1a96eca821061a3a9b13a6a78 (diff)
downloadPenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.tar.gz
PenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.tar.bz2
PenguinYippies-a5d9cd1b43c034953ec3cd60331aba6b9591c417.zip
Better setup for web build
Diffstat (limited to 'src')
-rw-r--r--src/game.c2
-rw-r--r--src/gameCommon.h7
-rw-r--r--src/main.c27
3 files changed, 24 insertions, 12 deletions
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 <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)
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 <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;
}
+