From 374ee2c16a3f9290f785eef71cef0eb68dea2e8d Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Thu, 15 Mar 2018 13:12:13 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 275 bytes modified --- 21g30t1e75.js | 78 +++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index 348de41..3ec99d2 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -228,45 +228,49 @@ GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation) { GameLib.CustomCode.prototype.advanceSnake = function(delta) { - this.advanceTime += delta; + this.advanceTime += delta; + + if (this.advanceTime > this.speed) { + this.advanceTime = 0; + } else { + return; + } + + var tail = this.snake.pop(); + var parent = null; + + var newSnake = []; + + while (this.snake.length > 0) { + + parent = this.snake.pop(); + + tail.position.x = parent.position.x; + tail.position.y = parent.position.y; + tail.orientation = parent.orientation; + + if (this.snake.length === 1) { + console.log('before head'); + } + + tail.applyToMesh(); + + newSnake.unshift(tail); + + tail = parent; + } + + tail.advance( + this.state.orientation + ); + + tail.applyToMesh(); + + newSnake.unshift(tail); + + this.snake = newSnake; - if (this.advanceTime > this.speed) { - this.advanceTime = 0; - } else { return; - } - - var tail = this.snake.pop(); - var parent = null; - - var newSnake = []; - - while (this.snake.length > 0) { - - parent = this.snake.pop(); - - tail.position.x = parent.position.x; - tail.position.y = parent.position.y; - tail.orientation = parent.orientation; - - tail.applyToMesh(); - - newSnake.unshift(tail); - - tail = parent; - } - - tail.advance( - this.state.orientation - ); - - tail.applyToMesh(); - - newSnake.unshift(tail); - - this.snake = newSnake; - - return; this.snake = this.snake.map(