Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 109 bytes modified
parent
c977c3ee27
commit
afcf48278f
|
@ -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);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue