From 10b5109e21b30c92a6e752bad1aca2d79fd6017a Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Wed, 22 Dec 2021 02:50:12 -0800 Subject: [PATCH] Fullscreen --- game.js | 13 ++++++++++++- index.js | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/game.js b/game.js index f2cca35..7d9dac7 100644 --- a/game.js +++ b/game.js @@ -200,7 +200,8 @@ function tagABlock(gl, params, objects) { // [x] better controls // [x] non-flowy water // [x] slightly cooler terrain -// [ ] fullscreen +// [x] double jump!! +// [x] fullscreen // [ ] a soundrack // [ ] trees and stuff // [ ] different biomes (with different noise stats) @@ -330,6 +331,16 @@ export function initUiListeners(params, canvas) { document.addEventListener('keyup', keyListener); }; 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) { diff --git a/index.js b/index.js index 6f2b895..45c735f 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,8 @@ import * as se3 from './se3'; async function main() { 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'); if (gl === null) {