User:Commander Bsyew/GameCloud.js

// Variables var wallImage = null; var keyImage = null; var backgroundImage = null; var characterImage = null; var departureImage = null; var trapImage = null; var gameModel = null; var gameMap = new Array; var gamePlayer = null; var gameEditor = null;

/** * Construct the page. * The used media need to be entirely loaded before. * Then we can init the game */ function init { wallImage = new Image; keyImage = new Image; backgroundImage = new Image; characterImage = new Image; departureImage = new Image; trapImage = new Image; // TODO Optimize the loading time wallImage.onload = function { keyImage.onload = function { backgroundImage.onload = function { characterImage.onload = function { departureImage.onload = function { trapImage.onload = function { // Some errors are not critical. Let's hide the splashscreen anyway. try { gameModel = sourceData.innerHTML; sourceData.innerHTML = "";

gamePlayer = new GamePlayer; document.onkeydown = gamePlayer.keyDown; document.onkeyup = gamePlayer.keyUp; gamePlayer.initGamePlayer;

gameEditor = new GameEditor; gameEditor.setGamePlayer(gamePlayer); gameEditor.initGameEditor; gamePlayer.setGameEditor(gameEditor); } catch(error) { alert('An error has occurred: ' + error); }							stopSplashscreen; }						trapImage.src = 'http://images2.wikia.nocookie.net/__cb20120611200515/gamecloud/images/3/3b/Bomb.png'; }					departureImage.src = 'http://images3.wikia.nocookie.net/gamecloud/images/4/48/Parchment.png'; }				characterImage.src = 'http://images3.wikia.nocookie.net/gamecloud/images/d/d8/Character.png'; }			backgroundImage.src = 'http://images3.wikia.nocookie.net/gamecloud/images/3/3f/Game_background.png'; }		keyImage.src = 'http://images3.wikia.nocookie.net/gamecloud/images/5/52/Key.png'; }	wallImage.src = 'http://images2.wikia.nocookie.net/gamecloud/images/3/3a/Brick_wall.jpg'; }