setOrientation()

This commit is contained in:
Alexander Popov 2021-07-08 00:09:08 +03:00
parent da870f3e08
commit 48a6c57741
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
2 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import config from '../app/config.json';
export function imagePreloader(images, callback) {
let counter = 0;
@ -19,3 +21,17 @@ export function shuffle(array) {
[array[i], array[j]] = [array[j], array[i]];
}
}
export function setOrientation(canvas) {
let landscape_orientation = null;
if (canvas.width >= canvas.height) landscape_orientation = true;
else landscape_orientation = false;
if (config.debug)
console.log(landscape_orientation ?
'Canvas orientation set to landscape' :
'Canvas orientation set to portrait');
return landscape_orientation;
}

View File

@ -37,10 +37,7 @@ window.onload = function() {
console.log(`Canvas size ${cW} x ${cH}`);
// set screen orientation by carculate canvas width & height
if (cW >= cH) { landscape_orientation = true; }
else { landscape_orientation = false; }
if (DEBUG)
console.log(landscape_orientation ? "Canvas orientation set to landscape" : "Canvas orientation set to portrait");
landscape_orientation = Engine.setOrientation(canvas)
let imageLogo = new Image();
imageLogo.src = "assets/logo.png";
@ -75,7 +72,6 @@ window.onload = function() {
Engine.shuffle(quest.answer);
});
// set all quest status 'not answered'
gameData.questions.forEach(element => element.status = null);