diff --git a/21g30t1e75.js b/21g30t1e75.js index 8b31200..da19301 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -175,37 +175,34 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { return; } - var head = this.snake[0].clone(); - head.advance(this.direction); - - var oldHead = this.snake.shift(); - oldHead.mesh.geometry = null; - oldHead.mesh.materials = null; - oldHead.mesh.remove(); - - var position = oldHead.position; - - var snake = [head]; + var position = null; this.snake.map( - function(body) { + function(body, index) { var tempPosition = { x : body.position.x, y : body.position.y }; - - body.position.x = position.x; - body.position.y = position.y; - snake.push(body); + if (index === 0) { + + position.x = body.position.x; + position.y = body.position.y; + + body.advance(this.direction); - position.x = tempPosition.x; - position.y = tempPosition.y; + } else { + body.position.x = position.x; + body.position.y = position.y; + + position.x = tempPosition.x; + position.y = tempPosition.y; + } + } ); - this.snake = snake; }.bind(this); /*