From d510bc9cee809e7b3c9ad374978523e34f88bb91 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 24 Mar 2018 15:31:25 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 189 bytes modified --- 21g30t1e75.js | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index f371768..5fcc875 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -250,7 +250,7 @@ GameLib.CustomCode.prototype.waitReload = function(delta) { this.state.exploding = false; if (this.state.lives <= 0) { - this.restore(); + this.restore(); this.gameOver(false); return; } @@ -832,11 +832,20 @@ GameLib.CustomCode.prototype.createFood = function(delta) { GameLib.CustomCode.prototype.gameOver = function(won) { this.state.gameOver = true; - this.state.message = { - text : "GAME OVER", - x : 127, - y : 256 - }; + + if (won) { + this.state.message = { + text: "YOU WON!", + x: 127, + y: 256 + }; + } else { + this.state.message = { + text: "GAME OVER", + x: 127, + y: 256 + }; + } this.displayHUD(); }.bind(this) @@ -1160,16 +1169,16 @@ GameLib.CustomCode.prototype.extend = function(gameObject, position, orientation this.gameOver(true); } - this.extendSpeedGrain = (GameLib.CustomCode.SPEED_INITIAL - GameLib.CustomCode.MAX_SPEED) / ((GameLib.CustomCode.GRID_WIDTH * GameLib.CustomCode.GRID_HEIGHT) - this.snake.length) - - this.speed -= this.extendSpeedGrain; - - if (this.speed < GameLib.CustomCode.MAX_SPEED) { - this.speed = GameLib.CustomCode.MAX_SPEED; - } - - console.log('speed = ' + this.speed); - + this.extendSpeedGrain = (GameLib.CustomCode.SPEED_INITIAL - GameLib.CustomCode.MAX_SPEED) / ((GameLib.CustomCode.GRID_WIDTH * GameLib.CustomCode.GRID_HEIGHT) - this.snake.length) + + this.speed -= this.extendSpeedGrain; + + if (this.speed < GameLib.CustomCode.MAX_SPEED) { + this.speed = GameLib.CustomCode.MAX_SPEED; + } + + console.log('speed = ' + this.speed); + }.bind(this); /** @@ -1224,10 +1233,10 @@ GameLib.CustomCode.prototype.powerup = function(gameObject) { } - console.log('speed = ' + this.speed); - console.log('animation speed = ' + this.animation.translationSpeed); - - + console.log('speed = ' + this.speed); + console.log('animation speed = ' + this.animation.translationSpeed); + + this.powerups.splice( this.powerups.indexOf(gameObject), 1