Load the highscore and display it on the screen

This commit is contained in:
Aaron Mueller 2013-04-25 21:30:57 +02:00
parent 648d6168aa
commit a213b83534

View file

@ -111,12 +111,10 @@
init: function() {
ig.input.bind(ig.KEY.ENTER, 'main-menu');
loadScores();
console.log('asdf');
this.loadScores();
},
update: function() {
console.log("asdfasdasdfsd");
if (ig.input.pressed('main-menu')) {
ig.system.setGame(StartScreen);
}
@ -124,9 +122,10 @@
},
loadScores: function() {
console.log('asdf');
ig.global.scores = undefined;
$.post('https://www.scoreoid.com/api/getScores', this.scoreoid, function(data) {
console.log(data);
ig.global.scores = data;
});
},
@ -136,8 +135,19 @@
draw: function() {
this.parent();
this.background.draw(0, 0);
this.font.draw('Score: ' + ig.global.score, 200, 50, ig.Font.ALIGN.CENTER);
this.font.draw('Press [ENTER] to move to the main menu', 200, 100, ig.Font.ALIGN.CENTER);
// Draw the current highscore if its loaded
if (ig.global.scores !== undefined) {
var ypos = 50;
for (var i=0; i<ig.global.scores.length; i++) {
var score = ig.global.scores[i];
this.font.draw(score.Score.score + ' ' + score.Player.username, 100, ypos, ig.Font.ALIGN.LEFT);
ypos += 50;
}
}
this.font.draw('Score: ' + ig.global.score, 200, 300, ig.Font.ALIGN.CENTER);
this.font.draw('Press [ENTER] to move to the main menu', 200, 350, ig.Font.ALIGN.CENTER);
}
});
@ -147,12 +157,19 @@
init: function() {
ig.input.bind(ig.KEY.ENTER, 'start-game');
ig.input.bind(ig.KEY.H, 'highscore'); // XXX: Just for debug purpose
},
update: function() {
if (ig.input.pressed('start-game')) {
ig.system.setGame(RunningGame);
}
// XXX: Just for debug purpose
if (ig.input.pressed('highscore')) {
ig.global.score = 1337;
ig.system.setGame(ScoreboardScreen);
}
this.parent();
},