From 4f32e36bb4bd76849e0e6d69716b86697498a047 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 24 Mar 2018 22:42:37 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 337 bytes modified --- 21g30t1e75.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index 20db861..b20a94e 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -226,7 +226,8 @@ this.state = { gameOver : false, muted : false, paused : false, - score : 0 + score : 0, + highscore : 0 }; GameLib.CustomCode.prototype.advanceSpeedTimer = function(delta) { @@ -261,7 +262,9 @@ GameLib.CustomCode.prototype.displayHUD = function() { this.canvasHUD.line(50, 38, 462, 38, 2, "#000000"); - this.canvasHUD.text('hiscore', 50, 32, '15px Pixeled', '#ffffff'); + var highscore = GameLib.Utils.PaddedText(5, '0', this.state.highscore + '') + 'cm'; + + this.canvasHUD.text('hiscore ' + highscore + 'cm', 50, 32, '15px Pixeled', '#ffffff'); var score = GameLib.Utils.PaddedText(5, '0', this.state.score + '') + 'cm'; @@ -1951,6 +1954,16 @@ GameLib.Event.Subscribe( }.bind(this) ) +GameLib.Event.Subscribe( + GameLib.Event.CUSTOM_DATA, + function(data) { + if (data.type === 'highscore') { + this.state.highscore = data.highscore; + this.displayHUD(); + } + }.bind(this) +) + this.displayHUD(); window.moveTo(0, 0); @@ -1975,6 +1988,8 @@ window.scroll(0,0); maxWindow(); + + GameLib.Event.Emit(GameLib.Event.GAME_LOADED); //@ sourceURL=entityLoaded.js \ No newline at end of file