From 56809c619dcc89564a38e38381726f71859f2179 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Thu, 11 Apr 2013 21:12:27 +0200 Subject: [PATCH] Finishing game states --- README.md | 4 ++-- dev/lib/game/main.js | 35 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a2a2ab3..2de70a0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -ARG-1 +[[ARG-1]] ===== -The first of many! :) \ No newline at end of file +The first of many! :) diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index 9dbd951..dad2121 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -19,12 +19,16 @@ pauseDialog: new ig.Image('media/pause_dialog.png'), score: {'ai': 1, 'human': 1}, showStats: false, - pause: false, + showPause: false, init: function() { ig.input.unbindAll(); + + // Menu navigation ig.input.bind(ig.KEY.ESC, 'escape'); ig.input.bind(ig.KEY.ENTER, 'enter'); + + // Game navigation ig.input.bind(ig.KEY.UP_ARROW, 'up'); ig.input.bind(ig.KEY.DOWN_ARROW, 'down'); ig.input.bind(ig.KEY.T, 'force-top'); @@ -38,8 +42,6 @@ ig.input.bind(ig.KEY.W, 'up'); ig.input.bind(ig.KEY.S, 'down'); - ig.input.bind(ig.KEY.SPACE, 'endgame'); - // Load the level this.loadLevel(LevelLevel1); }, @@ -47,23 +49,23 @@ update: function() { // The user is in the game stats menu, next stop: main menu if (this.showStats) { - if (ig.input.state('endgame')) { + if (ig.input.pressed('enter')) { this.showStats = false; ig.system.setGame(StartScreen); - //this.parent(); } return; } // User is in the pause menu - // TODO: Hier gehts weiter .... irgend was stimmt mit dem input state nicht ... - if (this.pause) { - if (ig.input.state('enter')) { + if (this.showPause) { + if (ig.input.pressed('enter')) { ig.system.setGame(StartScreen); + return; } - if (ig.input.state('escape')) { - this.pause = false; + if (ig.input.pressed('escape')) { + this.showPause = false; + return; } } @@ -74,11 +76,11 @@ // The User want back to the main menu inside a running game if (ig.input.pressed('escape')) { - this.pause = true; + this.showPause = true; } // The game is running - if (!this.showStats && !this.pause) { + if (!this.showStats && !this.showPause) { this.parent(); // Update entries and background } }, @@ -91,10 +93,10 @@ 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 [SPACE] to move to the main menu', 200, 100, ig.Font.ALIGN.CENTER); + this.font.draw('Press [ENTER] to move to the main menu', 200, 100, ig.Font.ALIGN.CENTER); } - if (this.pause) { + if (this.showPause) { this.pauseDialog.draw(150, 100); } } @@ -105,11 +107,12 @@ init: function() { ig.input.bind(ig.KEY.ENTER, 'start-game'); - //ig.input.bind(ig.KEY.SPACE, 'start'); // FIXME: collides with the stats screen }, update: function() { - if (ig.input.pressed('start-game')) ig.system.setGame(RunningGame); + if (ig.input.pressed('start-game')) { + ig.system.setGame(RunningGame); + } this.parent(); },