Extract the scoreboard
This commit is contained in:
parent
9f3c7a1252
commit
f163e34a70
4 changed files with 34 additions and 28 deletions
|
@ -17,7 +17,7 @@ ig.module(
|
||||||
|
|
||||||
check: function(other) {
|
check: function(other) {
|
||||||
if (other.name == 'ball') {
|
if (other.name == 'ball') {
|
||||||
ig.game.score[this.owner] -= 1;
|
ig.global.score[this.owner] -= 1;
|
||||||
other.reset();
|
other.reset();
|
||||||
this.looseSound.play();
|
this.looseSound.play();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,13 @@
|
||||||
.defines(function(){
|
.defines(function(){
|
||||||
RunningGame = ig.Game.extend({
|
RunningGame = ig.Game.extend({
|
||||||
font: new ig.Font( 'media/04b03.font.png' ),
|
font: new ig.Font( 'media/04b03.font.png' ),
|
||||||
statsBackground: new ig.Image('media/stats_screen.png'),
|
|
||||||
pauseDialog: new ig.Image('media/pause_dialog.png'),
|
pauseDialog: new ig.Image('media/pause_dialog.png'),
|
||||||
score: {'ai': 1, 'human': 1},
|
|
||||||
showStats: false,
|
|
||||||
showPause: false,
|
showPause: false,
|
||||||
clearColor: null,
|
clearColor: null,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
ig.input.unbindAll();
|
ig.input.unbindAll();
|
||||||
|
ig.global.score = {'ai': 1, 'human': 1};
|
||||||
|
|
||||||
// Menu navigation
|
// Menu navigation
|
||||||
ig.input.bind(ig.KEY.ESC, 'escape');
|
ig.input.bind(ig.KEY.ESC, 'escape');
|
||||||
|
@ -48,31 +46,22 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
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
|
// User is in the pause menu
|
||||||
if (this.showPause) {
|
if (this.showPause) {
|
||||||
if (ig.input.pressed('enter')) {
|
if (ig.input.pressed('escape')) {
|
||||||
ig.system.setGame(StartScreen);
|
ig.system.setGame(StartScreen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ig.input.pressed('escape')) {
|
if (ig.input.pressed('enter')) {
|
||||||
this.showPause = false;
|
this.showPause = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// One player has won the game
|
// One player has won the game
|
||||||
if (this.score.ai == 0 || this.score.human == 0) {
|
if (ig.global.score.ai == 0 || ig.global.score.human == 0) {
|
||||||
this.showStats = true;
|
ig.system.setGame(ScoreboardScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The User want back to the main menu inside a running game
|
// The User want back to the main menu inside a running game
|
||||||
|
@ -81,22 +70,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// The game is running
|
// The game is running
|
||||||
if (!this.showStats && !this.showPause) {
|
if (!this.showPause) this.parent();
|
||||||
this.parent(); // Update entries and background
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
draw: function() {
|
draw: function() {
|
||||||
ig.system.context.clearRect( 0 ,0, ig.system.realWidth, ig.system.realHeight );
|
ig.system.context.clearRect( 0 ,0, ig.system.realWidth, ig.system.realHeight );
|
||||||
this.parent(); // Draw entries and background
|
this.parent(); // Draw entries and background
|
||||||
this.font.draw(this.score.ai, 270, 25, ig.Font.ALIGN.CENTER);
|
this.font.draw(ig.global.score.ai, 270, 25, ig.Font.ALIGN.CENTER);
|
||||||
this.font.draw(this.score.human, 350, 25, ig.Font.ALIGN.CENTER);
|
this.font.draw(ig.global.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.showPause) {
|
if (this.showPause) {
|
||||||
this.pauseDialog.draw(150, 100);
|
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({
|
StartScreen = ig.Game.extend({
|
||||||
background: new ig.Image('media/main_screen.png'),
|
background: new ig.Image('media/main_screen.png'),
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 19 KiB |
3
doc/TODO
3
doc/TODO
|
@ -14,6 +14,9 @@ Initial release
|
||||||
* Display the Highscore in the game
|
* 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/)
|
* 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/)
|
* 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
|
* Put the Player (with name) on the highscore
|
||||||
|
|
||||||
## Nice to have
|
## Nice to have
|
||||||
|
|
Loading…
Reference in a new issue