Finishing game states
This commit is contained in:
parent
187dde1b50
commit
56809c619d
2 changed files with 21 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
ARG-1
|
[[ARG-1]]
|
||||||
=====
|
=====
|
||||||
|
|
||||||
The first of many! :)
|
The first of many! :)
|
||||||
|
|
|
@ -19,12 +19,16 @@
|
||||||
pauseDialog: new ig.Image('media/pause_dialog.png'),
|
pauseDialog: new ig.Image('media/pause_dialog.png'),
|
||||||
score: {'ai': 1, 'human': 1},
|
score: {'ai': 1, 'human': 1},
|
||||||
showStats: false,
|
showStats: false,
|
||||||
pause: false,
|
showPause: false,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
ig.input.unbindAll();
|
ig.input.unbindAll();
|
||||||
|
|
||||||
|
// Menu navigation
|
||||||
ig.input.bind(ig.KEY.ESC, 'escape');
|
ig.input.bind(ig.KEY.ESC, 'escape');
|
||||||
ig.input.bind(ig.KEY.ENTER, 'enter');
|
ig.input.bind(ig.KEY.ENTER, 'enter');
|
||||||
|
|
||||||
|
// Game navigation
|
||||||
ig.input.bind(ig.KEY.UP_ARROW, 'up');
|
ig.input.bind(ig.KEY.UP_ARROW, 'up');
|
||||||
ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
|
ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
|
||||||
ig.input.bind(ig.KEY.T, 'force-top');
|
ig.input.bind(ig.KEY.T, 'force-top');
|
||||||
|
@ -38,8 +42,6 @@
|
||||||
ig.input.bind(ig.KEY.W, 'up');
|
ig.input.bind(ig.KEY.W, 'up');
|
||||||
ig.input.bind(ig.KEY.S, 'down');
|
ig.input.bind(ig.KEY.S, 'down');
|
||||||
|
|
||||||
ig.input.bind(ig.KEY.SPACE, 'endgame');
|
|
||||||
|
|
||||||
// Load the level
|
// Load the level
|
||||||
this.loadLevel(LevelLevel1);
|
this.loadLevel(LevelLevel1);
|
||||||
},
|
},
|
||||||
|
@ -47,23 +49,23 @@
|
||||||
update: function() {
|
update: function() {
|
||||||
// The user is in the game stats menu, next stop: main menu
|
// The user is in the game stats menu, next stop: main menu
|
||||||
if (this.showStats) {
|
if (this.showStats) {
|
||||||
if (ig.input.state('endgame')) {
|
if (ig.input.pressed('enter')) {
|
||||||
this.showStats = false;
|
this.showStats = false;
|
||||||
ig.system.setGame(StartScreen);
|
ig.system.setGame(StartScreen);
|
||||||
//this.parent();
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// User is in the pause menu
|
// User is in the pause menu
|
||||||
// TODO: Hier gehts weiter .... irgend was stimmt mit dem input state nicht ...
|
if (this.showPause) {
|
||||||
if (this.pause) {
|
if (ig.input.pressed('enter')) {
|
||||||
if (ig.input.state('enter')) {
|
|
||||||
ig.system.setGame(StartScreen);
|
ig.system.setGame(StartScreen);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ig.input.state('escape')) {
|
if (ig.input.pressed('escape')) {
|
||||||
this.pause = false;
|
this.showPause = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +76,11 @@
|
||||||
|
|
||||||
// The User want back to the main menu inside a running game
|
// The User want back to the main menu inside a running game
|
||||||
if (ig.input.pressed('escape')) {
|
if (ig.input.pressed('escape')) {
|
||||||
this.pause = true;
|
this.showPause = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The game is running
|
// The game is running
|
||||||
if (!this.showStats && !this.pause) {
|
if (!this.showStats && !this.showPause) {
|
||||||
this.parent(); // Update entries and background
|
this.parent(); // Update entries and background
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -91,10 +93,10 @@
|
||||||
if (this.showStats) {
|
if (this.showStats) {
|
||||||
this.statsBackground.draw(0, 0);
|
this.statsBackground.draw(0, 0);
|
||||||
this.font.draw('You ' + (this.score.ai == 0 ? 'won!' : 'loose!'), 200, 50, ig.Font.ALIGN.CENTER);
|
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);
|
this.pauseDialog.draw(150, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,11 +107,12 @@
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
ig.input.bind(ig.KEY.ENTER, 'start-game');
|
ig.input.bind(ig.KEY.ENTER, 'start-game');
|
||||||
//ig.input.bind(ig.KEY.SPACE, 'start'); // FIXME: collides with the stats screen
|
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
if (ig.input.pressed('start-game')) ig.system.setGame(RunningGame);
|
if (ig.input.pressed('start-game')) {
|
||||||
|
ig.system.setGame(RunningGame);
|
||||||
|
}
|
||||||
this.parent();
|
this.parent();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue