From 071e1e81f440aae6bbbb72c699c6001790ff0841 Mon Sep 17 00:00:00 2001 From: k00lagin Date: Tue, 7 May 2024 20:39:13 +0500 Subject: [PATCH 1/2] Implement fullscreen --- raylib.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/raylib.js b/raylib.js index a6a0154..60c7ed4 100644 --- a/raylib.js +++ b/raylib.js @@ -117,6 +117,18 @@ class RaylibJs { return false; } + IsWindowFullscreen() { + return document.fullscreenElement && document.fullscreenElement === this.ctx.canvas; + } + + ToggleFullscreen() { + if (this.IsWindowFullscreen()) { + document.exitFullscreen() + } else { + this.ctx.canvas.requestFullscreen(); + } + } + SetTargetFPS(fps) { console.log(`The game wants to run at ${fps} FPS, but in Web we gonna just ignore it.`); this.targetFPS = fps; From 723678e21a94a559feb959f71799a88edf8e295d Mon Sep 17 00:00:00 2001 From: k00lagin Date: Thu, 9 May 2024 13:24:43 +0500 Subject: [PATCH 2/2] Add fullscreen function to the snake game --- examples/tsoding_snake/tsoding_snake.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/tsoding_snake/tsoding_snake.c b/examples/tsoding_snake/tsoding_snake.c index 32cbdf5..912ff66 100644 --- a/examples/tsoding_snake/tsoding_snake.c +++ b/examples/tsoding_snake/tsoding_snake.c @@ -710,6 +710,9 @@ void game_update(f32 dt) if (IsKeyPressed(KEY_R)) { game_restart(game.width, game.height); } + if ((IsKeyDown(KEY_LEFT_ALT) || IsKeyDown(KEY_RIGHT_ALT)) && IsKeyPressed(KEY_ENTER)) { + ToggleFullscreen(); + } game.step_cooldown -= dt; if (game.step_cooldown <= 0.0f) {