From 22117eb8f8ada43e6ef616afef83be5fcabc5331 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 12 Mar 2018 21:25:43 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 86 bytes modified --- 21g30t1e75.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index 210761a..197a228 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -187,26 +187,20 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { var head = this.snake[0].clone(); head.advance(); - this.snake = this.snake.reduce( + var snake = this.snake.reduce( function(result, body, index) { - if ((index + 1) === this.snake.length) { + if ((index + 1) >= this.snake.length) { /** * we're done */ return result; - } else if ((index) === this.snake.length) { - /** - * Pop it - */ - this.snake[index].mesh.geometry = null; - this.snake[index].mesh.materials = null; - this.snake[index].mesh.remove(); + } else { /** * Move the body over */ - result.push(this.snake[index]); + result.push(this.snake[index + 1]); } return result; @@ -215,6 +209,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { [head] ) + var tail = this.snake.pop(); + tail.mesh.geometry = null; + tail.mesh.materials = null; + tail.mesh.remove(); + }.bind(this); /*