Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/tsoding_snake/tsoding_snake.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions raylib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down