let game, context; if (window.cordova) { document.addEventListener("deviceready", start, false); } else { start(); } function start() { if (typeof StatusBar !== 'undefined') { StatusBar.hide(); } init(); loop(); } function init() { let canvas = document.getElementById('canvas'); game = new Game(canvas); } function loop() { // Manage physics game.update(); // Do rendering game.render(); requestAnimationFrame(loop); }