Fullscreen

This commit is contained in:
Paul Mathieu 2021-12-22 02:50:12 -08:00
parent a1d117595f
commit 10b5109e21
2 changed files with 14 additions and 1 deletions

13
game.js
View File

@ -200,7 +200,8 @@ function tagABlock(gl, params, objects) {
// [x] better controls // [x] better controls
// [x] non-flowy water // [x] non-flowy water
// [x] slightly cooler terrain // [x] slightly cooler terrain
// [ ] fullscreen // [x] double jump!!
// [x] fullscreen
// [ ] a soundrack // [ ] a soundrack
// [ ] trees and stuff // [ ] trees and stuff
// [ ] different biomes (with different noise stats) // [ ] different biomes (with different noise stats)
@ -330,6 +331,16 @@ export function initUiListeners(params, canvas) {
document.addEventListener('keyup', keyListener); document.addEventListener('keyup', keyListener);
}; };
canvas.onclick = canvasClickHandler; canvas.onclick = canvasClickHandler;
document.addEventListener('keydown', e => {
switch (e.code) {
case 'F11':
canvas.requestFullscreen().then(() => {
console.log('full screen!!');
});
break;
}
});
} }
export function tick(time, gl, params) { export function tick(time, gl, params) {

View File

@ -4,6 +4,8 @@ import * as se3 from './se3';
async function main() { async function main() {
const canvas = document.querySelector('#game'); const canvas = document.querySelector('#game');
// adjust canvas aspect ratio to that of the screen
canvas.height = screen.height / screen.width * canvas.width;
const gl = canvas.getContext('webgl'); const gl = canvas.getContext('webgl');
if (gl === null) { if (gl === null) {