diff --git a/src/Tree.cpp b/src/Tree.cpp index d47d952..e1b147f 100644 --- a/src/Tree.cpp +++ b/src/Tree.cpp @@ -12,7 +12,7 @@ Tree::Tree(int size) start.x = size / 2; start.y = size; - branches.assign(11, {0}); + branches.assign(11, {}); } Tree::~Tree() diff --git a/src/main.cpp b/src/main.cpp index 2818fcb..bf2d2df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,20 @@ #include "raylib.h" #include "App.hpp" +#if defined(PLATFORM_WEB) +#include +#endif + +static App app; + +void UpdateDrawFrame() +{ + app.update(); + BeginDrawing(); + app.draw(); + EndDrawing(); +} + int main(void) { char name[] = "treender"; @@ -14,17 +28,19 @@ int main(void) #else InitWindow(screenWidth, screenHeight, name); #endif - SetTargetFPS(60); - App app; app.init(screenWidth, screenHeight); + +#if defined(PLATFORM_WEB) + emscripten_set_main_loop(UpdateDrawFrame, 0, 1); +#else + SetTargetFPS(60); while (!WindowShouldClose()) { - app.update(); - BeginDrawing(); - app.draw(); - EndDrawing(); + UpdateDrawFrame(); } +#endif + app.deinit(); CloseWindow();