From a213b835347b2a47768bf6ced164ae79ea08110e Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Thu, 25 Apr 2013 21:30:57 +0200 Subject: [PATCH] Load the highscore and display it on the screen --- dev/lib/game/main.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index bf2c8ee..61c252f 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -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