setOrientation()
This commit is contained in:
parent
da870f3e08
commit
48a6c57741
16
js/engine.js
16
js/engine.js
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user