Path: blob/main/public/games/files/algaes-escapade/js/main.js
1036 views
gamejs = require('gamejs');1font = require('gamejs/font');23//Preload all the required images4gamejs.preload([5'img/splash-screen.png','img/new-game.png', 'img/bg.png','img/player.png',6'img/blank.png','img/switch.png','img/door.png','img/goal.png',7'img/platform-left.png','img/platform-right.png',8'img/platform-middle.png', 'img/selected.png',9'img/scorecard-background.png','img/game-window.png',10'img/reset.png', 'img/star-off.png', 'img/star-on.png',11'img/menu-button.png', 'img/next-button.png', 'img/end.png'12]);1314gamejs.ready(function() {1516var display = gamejs.display.setMode([800, 600]);1718//Ensure that all required files are included19include_once([20'lib/startMenu.js'21]);2223var mainSurface = gamejs.display.getSurface();24var mainWindow = new startMenu();25var self = this;2627// msDuration = time since last tick() call28var tick = function(msDuration){29mainSurface.fill("#FFFFFF");3031//Handle user input32mainWindow.handleInput( mainSurface );3334//Update the worlds objects35mainWindow.update( msDuration );3637//Draw the new objects38mainWindow.draw( mainSurface );39};4041//Set up listeners for the body when a scorecard is present42$('body').keydown(function(event){43//Only check key presses if the scorcard is shown44if ( $('#game_scorecard').is(":visible") )45{46switch ( event.keyCode )47{48//Enter and e will all move to the next level49case 13:50case 69:51$('#game_scorecard .nextLevel').click();52event.preventDefault();53break;54//Escape will quit to the menu55case 27:56$('#game_scorecard .mainMenu').click();57event.preventDefault();58break;59//r will reset the level60case 82:61$('#game_scorecard .resetLevel').click();62event.preventDefault();63break;64}65}66});6768//Remove the loading bar69$('#preload').remove();70$('#gameWindow').show();7172//Set up the tick function, run at 60fps73gamejs.time.fpsCallback(tick, self, 60);74});757677