From 968e5e2c31104f33db8f688e09536691939b3deb Mon Sep 17 00:00:00 2001 From: AntonPieper Date: Mon, 12 Feb 2024 12:46:18 +0100 Subject: [PATCH 1/5] add asyncify - uses `asyncify-wasm` by GoogleChromeLabs - makes raylib.js an ES6 Module - allows 1:1 mapping from native to web - move `onchange` from index.html select box due to ES6 modules --- build.sh | 3 + examples/core_basic_screen_manager.c | 211 +++++++++++++-------------- examples/core_basic_window.c | 25 +--- examples/core_input_keys.c | 59 +++----- examples/core_input_mouse_wheel.c | 75 +++++----- examples/shapes_colors_palette.c | 117 +++++++-------- game.c | 6 - index.html | 9 +- raylib.js | 105 +++++++------ wasm/core_basic_screen_manager.wasm | Bin 3014 -> 8484 bytes wasm/core_basic_window.wasm | Bin 1024 -> 2203 bytes wasm/core_input_keys.wasm | Bin 1584 -> 3685 bytes wasm/core_input_mouse_wheel.wasm | Bin 1592 -> 5208 bytes wasm/game.wasm | Bin 1855 -> 4748 bytes wasm/shapes_colors_palette.wasm | Bin 4975 -> 13997 bytes 15 files changed, 293 insertions(+), 317 deletions(-) diff --git a/build.sh b/build.sh index 60ccd66..d60f94e 100755 --- a/build.sh +++ b/build.sh @@ -17,3 +17,6 @@ clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/shapes_colors_palette.wasm ./examples/shapes_colors_palette.c -DPLATFORM_WEB clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/game.wasm game.c -DPLATFORM_WEB clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/core_input_mouse_wheel.wasm ./examples/core_input_mouse_wheel.c -DPLATFORM_WEB + +# Instrument all wasm files with Asyncify +ls wasm | xargs -I{} wasm-opt --asyncify wasm/{} -o wasm/{} diff --git a/examples/core_basic_screen_manager.c b/examples/core_basic_screen_manager.c index 6220c35..728ef12 100644 --- a/examples/core_basic_screen_manager.c +++ b/examples/core_basic_screen_manager.c @@ -15,117 +15,11 @@ #include "raylib.h" -void raylib_js_set_entry(void (*entry)(void)); - //------------------------------------------------------------------------------------------ // Types and Structures Definition //------------------------------------------------------------------------------------------ typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; -const int screenWidth = 800; -const int screenHeight = 450; -GameScreen currentScreen = LOGO; -int framesCounter = 0; // Useful to count frames - -void GameFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - switch(currentScreen) - { - case LOGO: - { - // TODO: Update LOGO screen variables here! - - framesCounter++; // Count frames - - // Wait for 2 seconds (120 frames) before jumping to TITLE screen - if (framesCounter > 120) - { - currentScreen = TITLE; - } - } break; - case TITLE: - { - // TODO: Update TITLE screen variables here! - - // Press enter to change to GAMEPLAY screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) - { - currentScreen = GAMEPLAY; - } - } break; - case GAMEPLAY: - { - // TODO: Update GAMEPLAY screen variables here! - - // Press enter to change to ENDING screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) - { - currentScreen = ENDING; - } - } break; - case ENDING: - { - // TODO: Update ENDING screen variables here! - - // Press enter to return to TITLE screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) - { - currentScreen = TITLE; - } - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: - { - // TODO: Draw LOGO screen here! - DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); - DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); - - } break; - case TITLE: - { - // TODO: Draw TITLE screen here! - DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); - DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); - DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN); - - } break; - case GAMEPLAY: - { - // TODO: Draw GAMEPLAY screen here! - DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE); - DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON); - - } break; - case ENDING: - { - // TODO: Draw ENDING screen here! - DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); - DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -133,21 +27,117 @@ int main(void) { // Initialization //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - basic screen manager"); + GameScreen currentScreen = LOGO; + // TODO: Initialize all required variables and load all required data here! + int framesCounter = 0; // Useful to count frames + SetTargetFPS(60); // Set desired framerate (frames-per-second) //-------------------------------------------------------------------------------------- -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - GameFrame(); + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) + { + case LOGO: + { + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + currentScreen = TITLE; + } + } break; + case TITLE: + { + // TODO: Update TITLE screen variables here! + + // Press enter to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = GAMEPLAY; + } + } break; + case GAMEPLAY: + { + // TODO: Update GAMEPLAY screen variables here! + + // Press enter to change to ENDING screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = ENDING; + } + } break; + case ENDING: + { + // TODO: Update ENDING screen variables here! + + // Press enter to return to TITLE screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = TITLE; + } + } break; + default: break; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: + { + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); + + } break; + case TITLE: + { + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN); + + } break; + case GAMEPLAY: + { + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON); + + } break; + case ENDING: + { + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE); + + } break; + default: break; + } + + EndDrawing(); + //---------------------------------------------------------------------------------- } // De-Initialization @@ -157,7 +147,6 @@ int main(void) CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- -#endif return 0; } diff --git a/examples/core_basic_window.c b/examples/core_basic_window.c index 2790222..a925a39 100644 --- a/examples/core_basic_window.c +++ b/examples/core_basic_window.c @@ -23,19 +23,6 @@ #include "raylib.h" -void raylib_js_set_entry(void (*entry)(void)); - -void GameFrame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); - - EndDrawing(); -} - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -51,9 +38,6 @@ int main(void) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -64,7 +48,13 @@ int main(void) // Draw //---------------------------------------------------------------------------------- - GameFrame(); + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); + + EndDrawing(); //---------------------------------------------------------------------------------- } @@ -72,7 +62,6 @@ int main(void) //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- -#endif return 0; } diff --git a/examples/core_input_keys.c b/examples/core_input_keys.c index cdc45e2..511e101 100644 --- a/examples/core_input_keys.c +++ b/examples/core_input_keys.c @@ -13,33 +13,6 @@ #include "raylib.h" -void raylib_js_set_entry(void (*entry)(void)); -Vector2 ballPosition = { 0 }; - -void GameFrame() -{ - // Update - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; - if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; - if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; - if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY); - - DrawCircleV(ballPosition, 50, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -52,24 +25,40 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); - ballPosition.x = (float)screenWidth/2; - ballPosition.y = (float)screenHeight/2; + Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - GameFrame(); + // Update + //---------------------------------------------------------------------------------- + if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; + if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; + if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; + if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY); + + DrawCircleV(ballPosition, 50, MAROON); + + EndDrawing(); + //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- -#endif + return 0; -} \ No newline at end of file +} diff --git a/examples/core_input_mouse_wheel.c b/examples/core_input_mouse_wheel.c index 84350f0..f6e89c5 100644 --- a/examples/core_input_mouse_wheel.c +++ b/examples/core_input_mouse_wheel.c @@ -1,8 +1,8 @@ /******************************************************************************************* * -* raylib [core] example - Keyboard input +* raylib [core] example - Mouse input * -* Example originally created with raylib 1.0, last time updated with raylib 1.0 +* Example originally created with raylib 1.0, last time updated with raylib 4.0 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software @@ -13,35 +13,6 @@ #include "raylib.h" -void raylib_js_set_entry(void (*entry)(void)); - -const int screenWidth = 800; -const int screenHeight = 450; -int boxPositionY = screenHeight/2 - 40; -int scrollSpeed = 4; // Scrolling speed in pixels -Vector2 ballPosition = { 0 }; - -void GameFrame() -{ - // Update - //---------------------------------------------------------------------------------- - boxPositionY -= (GetMouseWheelMove()*scrollSpeed); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON); - - DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY); - DrawText(TextFormat("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY); - - EndDrawing(); -} - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -49,23 +20,51 @@ int main(void) { // Initialization //-------------------------------------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel"); + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); + + Vector2 ballPosition = { -100.0f, -100.0f }; + Color ballColor = DARKBLUE; SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else + //--------------------------------------------------------------------------------------- + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - GameFrame(); + // Update + //---------------------------------------------------------------------------------- + ballPosition = GetMousePosition(); + + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON; + else if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) ballColor = LIME; + else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) ballColor = DARKBLUE; + else if (IsMouseButtonPressed(MOUSE_BUTTON_SIDE)) ballColor = PURPLE; + else if (IsMouseButtonPressed(MOUSE_BUTTON_EXTRA)) ballColor = YELLOW; + else if (IsMouseButtonPressed(MOUSE_BUTTON_FORWARD)) ballColor = ORANGE; + else if (IsMouseButtonPressed(MOUSE_BUTTON_BACK)) ballColor = BEIGE; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawCircleV(ballPosition, 40, ballColor); + + DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- -#endif + return 0; } diff --git a/examples/shapes_colors_palette.c b/examples/shapes_colors_palette.c index 3cd0e00..8d05266 100644 --- a/examples/shapes_colors_palette.c +++ b/examples/shapes_colors_palette.c @@ -12,66 +12,8 @@ ********************************************************************************************/ #include "raylib.h" -#define MAX_COLORS_COUNT 21 // Number of colors available - -void raylib_js_set_entry(void (*entry)(void)); - -Color colors[MAX_COLORS_COUNT] = { - DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, - GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, - GREEN, SKYBLUE, PURPLE, BEIGE }; - -const char *colorNames[MAX_COLORS_COUNT] = { - "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE", - "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN", - "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" }; - -Rectangle colorsRecs[MAX_COLORS_COUNT] = { 0 }; // Rectangles array - -int colorState[MAX_COLORS_COUNT] = { 0 }; // Color state: 0-DEFAULT, 1-MOUSE_HOVER - -Vector2 mousePoint = { 0.0f, 0.0f }; - - -void GameFrame() -{ - // Update - //---------------------------------------------------------------------------------- - mousePoint = GetMousePosition(); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) - { - if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) colorState[i] = 1; - else colorState[i] = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("raylib colors palette", 28, 42, 20, BLACK); - DrawText("press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) // Draw all rectangles - { - DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i]? 0.6f : 1.0f)); - - if (IsKeyDown(KEY_SPACE) || colorState[i]) - { - DrawRectangle((int)colorsRecs[i].x, (int)(colorsRecs[i].y + colorsRecs[i].height - 26), (int)colorsRecs[i].width, 20, BLACK); - DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f)); - DrawText(colorNames[i], (int)(colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12), - (int)(colorsRecs[i].y + colorsRecs[i].height - 20), 10, colors[i]); - } - } - - EndDrawing(); - //---------------------------------------------------------------------------------- -} +#define MAX_COLORS_COUNT 21 // Number of colors available //------------------------------------------------------------------------------------ // Program main entry point @@ -85,6 +27,17 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette"); + Color colors[MAX_COLORS_COUNT] = { + DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, + GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, + GREEN, SKYBLUE, PURPLE, BEIGE }; + + const char *colorNames[MAX_COLORS_COUNT] = { + "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE", + "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN", + "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" }; + + Rectangle colorsRecs[MAX_COLORS_COUNT] = { 0 }; // Rectangles array // Fills colorsRecs data (for every rectangle) for (int i = 0; i < MAX_COLORS_COUNT; i++) @@ -95,23 +48,57 @@ int main(void) colorsRecs[i].height = 100.0f; } + int colorState[MAX_COLORS_COUNT] = { 0 }; // Color state: 0-DEFAULT, 1-MOUSE_HOVER + Vector2 mousePoint = { 0.0f, 0.0f }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - GameFrame(); + // Update + //---------------------------------------------------------------------------------- + mousePoint = GetMousePosition(); + + for (int i = 0; i < MAX_COLORS_COUNT; i++) + { + if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) colorState[i] = 1; + else colorState[i] = 0; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("raylib colors palette", 28, 42, 20, BLACK); + DrawText("press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY); + + for (int i = 0; i < MAX_COLORS_COUNT; i++) // Draw all rectangles + { + DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i]? 0.6f : 1.0f)); + + if (IsKeyDown(KEY_SPACE) || colorState[i]) + { + DrawRectangle((int)colorsRecs[i].x, (int)(colorsRecs[i].y + colorsRecs[i].height - 26), (int)colorsRecs[i].width, 20, BLACK); + DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f)); + DrawText(colorNames[i], (int)(colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12), + (int)(colorsRecs[i].y + colorsRecs[i].height - 20), 10, colors[i]); + } + } + + EndDrawing(); + //---------------------------------------------------------------------------------- } + // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- -#endif + return 0; -} \ No newline at end of file +} diff --git a/game.c b/game.c index d3f9da1..52c616b 100644 --- a/game.c +++ b/game.c @@ -7,8 +7,6 @@ static Vector2 ball_position = {0}; static Vector2 ball_velocity = {200, 200}; -void raylib_js_set_entry(void (*entry)(void)); - void GameFrame() { BeginDrawing(); @@ -41,13 +39,9 @@ int main() ball_position.x = w/2; ball_position.y = h/2; -#ifdef PLATFORM_WEB - raylib_js_set_entry(GameFrame); -#else while (!WindowShouldClose()) { GameFrame(); } CloseWindow(); -#endif return 0; } diff --git a/index.html b/index.html index 5f29ff6..32dfee8 100644 --- a/index.html +++ b/index.html @@ -34,15 +34,15 @@ src: url(fonts/acme_7_wide_xtnd.woff); } - - -