diff --git a/21g30t1e75.js b/21g30t1e75.js index dd228ad..a5ad13b 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -187,35 +187,24 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { var head = this.snake[0].clone(); head.advance(); - var snake = this.snake.reduce( - function(result, body, index) { - - if ((index + 1) >= this.snake.length) { - /** - * we're done - */ - return result; - - } else { - /** - * Move the body over - */ - result.push(this.snake[index + 1]); - } - - return result; - - }.bind(this), - [head] - ) + var oldHead = this.snake.shift(); + oldHead.mesh.geometry = null; + oldHead.mesh.materials = null; + oldHead.mesh.remove(); - var tail = this.snake.pop(); - tail.mesh.geometry = null; - tail.mesh.materials = null; - tail.mesh.remove(); + var oldTail = this.snake.pop(); - this.snake = snake; + var snake = [head]; + this.snake.map( + function(body) { + snake.push(body); + } + ); + + snake.push(oldTail); + + this.snake = snake; }.bind(this); /*