diff --git a/dev/lib/game/entities/goal.js b/dev/lib/game/entities/goal.js index f30fc28..d567dc9 100644 --- a/dev/lib/game/entities/goal.js +++ b/dev/lib/game/entities/goal.js @@ -17,7 +17,7 @@ ig.module( check: function(other) { if (other.name == 'ball') { - ig.game.score[this.owner] -= 1; + ig.global.score[this.owner] -= 1; other.reset(); this.looseSound.play(); } diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index a5dec58..a280290 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -15,15 +15,13 @@ .defines(function(){ RunningGame = ig.Game.extend({ font: new ig.Font( 'media/04b03.font.png' ), - statsBackground: new ig.Image('media/stats_screen.png'), pauseDialog: new ig.Image('media/pause_dialog.png'), - score: {'ai': 1, 'human': 1}, - showStats: false, showPause: false, clearColor: null, init: function() { ig.input.unbindAll(); + ig.global.score = {'ai': 1, 'human': 1}; // Menu navigation ig.input.bind(ig.KEY.ESC, 'escape'); @@ -48,31 +46,22 @@ }, update: function() { - // The user is in the game stats menu, next stop: main menu - if (this.showStats) { - if (ig.input.pressed('enter')) { - this.showStats = false; - ig.system.setGame(StartScreen); - } - return; - } - // User is in the pause menu if (this.showPause) { - if (ig.input.pressed('enter')) { + if (ig.input.pressed('escape')) { ig.system.setGame(StartScreen); return; } - if (ig.input.pressed('escape')) { + if (ig.input.pressed('enter')) { this.showPause = false; return; } } // One player has won the game - if (this.score.ai == 0 || this.score.human == 0) { - this.showStats = true; + if (ig.global.score.ai == 0 || ig.global.score.human == 0) { + ig.system.setGame(ScoreboardScreen); } // The User want back to the main menu inside a running game @@ -81,22 +70,14 @@ } // The game is running - if (!this.showStats && !this.showPause) { - this.parent(); // Update entries and background - } + if (!this.showPause) this.parent(); }, draw: function() { ig.system.context.clearRect( 0 ,0, ig.system.realWidth, ig.system.realHeight ); this.parent(); // Draw entries and background - this.font.draw(this.score.ai, 270, 25, ig.Font.ALIGN.CENTER); - this.font.draw(this.score.human, 350, 25, ig.Font.ALIGN.CENTER); - - if (this.showStats) { - this.statsBackground.draw(0, 0); - this.font.draw('You ' + (this.score.ai == 0 ? 'won!' : 'loose!'), 200, 50, ig.Font.ALIGN.CENTER); - this.font.draw('Press [ENTER] to move to the main menu', 200, 100, ig.Font.ALIGN.CENTER); - } + this.font.draw(ig.global.score.ai, 270, 25, ig.Font.ALIGN.CENTER); + this.font.draw(ig.global.score.human, 350, 25, ig.Font.ALIGN.CENTER); if (this.showPause) { this.pauseDialog.draw(150, 100); @@ -104,6 +85,28 @@ } }); + ScoreboardScreen = ig.Game.extend({ + font: new ig.Font( 'media/04b03.font.png' ), + background: new ig.Image('media/stats_screen.png'), + + init: function() { + ig.input.bind(ig.KEY.ENTER, 'main-menu'); + }, + update: function() { + if (ig.input.pressed('main-menu')) { + ig.system.setGame(StartScreen); + } + this.parent(); + }, + + draw: function() { + this.parent(); + this.background.draw(0, 0); + this.font.draw('You ' + (ig.global.score.ai == 0 ? 'won!' : 'loose!'), 200, 50, ig.Font.ALIGN.CENTER); + this.font.draw('Press [ENTER] to move to the main menu', 200, 100, ig.Font.ALIGN.CENTER); + } + }); + StartScreen = ig.Game.extend({ background: new ig.Image('media/main_screen.png'), diff --git a/dev/media/pause_dialog.png b/dev/media/pause_dialog.png index 68942b8..55f76e5 100644 Binary files a/dev/media/pause_dialog.png and b/dev/media/pause_dialog.png differ diff --git a/doc/TODO b/doc/TODO index d9a47ee..5572f9d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -14,6 +14,9 @@ Initial release * Display the Highscore in the game * An special effect on ball hit (sprite/glor/whatever) (http://clokwork.net/2012/03/07/particle-generation-in-impactjs/) * Highscore-Script (http://www.holoville.com/blog/?p=948, http://www.scoreoid.net/) + * username: arg + * email: mail@aaron-mueller.de + * passwort: iYon4OIgSy9 * Put the Player (with name) on the highscore ## Nice to have