escalator-web/src/main.js

36 lines
491 B
JavaScript
Raw Permalink Normal View History

let game, context;
2018-08-20 17:22:33 +02:00
2018-08-23 10:20:21 +02:00
if (window.cordova) {
document.addEventListener("deviceready", start, false);
} else {
start();
}
2018-08-22 17:47:44 +02:00
2018-08-23 10:20:21 +02:00
function start() {
2018-08-22 17:47:44 +02:00
if (typeof StatusBar !== 'undefined') {
StatusBar.hide();
}
init();
loop();
2018-08-23 10:20:21 +02:00
}
2018-08-20 17:22:33 +02:00
function init() {
2018-08-21 09:36:14 +02:00
2018-08-21 15:58:08 +02:00
let canvas = document.getElementById('canvas');
game = new Game(canvas);
2018-08-20 17:22:33 +02:00
}
2018-08-21 09:36:14 +02:00
function loop() {
2018-08-20 17:22:33 +02:00
// Manage physics
2018-08-21 15:58:08 +02:00
game.update();
2018-08-20 17:22:33 +02:00
// Do rendering
2018-08-21 15:58:08 +02:00
game.render();
2018-08-20 17:22:33 +02:00
2018-08-21 09:36:14 +02:00
requestAnimationFrame(loop);
2018-08-20 17:22:33 +02:00
}
2018-08-21 09:36:14 +02:00