Finishing game states

This commit is contained in:
Aaron Mueller 2013-04-11 21:12:27 +02:00
parent 187dde1b50
commit 56809c619d
2 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,4 @@
ARG-1
[[ARG-1]]
=====
The first of many! :)
The first of many! :)

View file

@ -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();
},