Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 109 bytes modified

beta.r3js.org
-=yb4f310 2018-03-13 12:29:04 +01:00
parent c977c3ee27
commit afcf48278f
1 changed files with 16 additions and 19 deletions

View File

@ -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);
/*