Skip to content

Commit

Permalink
Implement fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
k00lagin committed May 7, 2024
1 parent a71e743 commit fdfbab2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion raylib.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RaylibJs {
return;
}

const canvas = document.getElementById(canvasId);
let canvas = document.getElementById(canvasId);
this.ctx = canvas.getContext("2d");
if (this.ctx === null) {
throw new Error("Could not create 2d canvas context");
Expand Down 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

0 comments on commit fdfbab2

Please sign in to comment.