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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var head = this.snake[0].clone();
|
var position = null;
|
||||||
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];
|
|
||||||
|
|
||||||
this.snake.map(
|
this.snake.map(
|
||||||
function(body) {
|
function(body, index) {
|
||||||
|
|
||||||
var tempPosition = {
|
var tempPosition = {
|
||||||
x : body.position.x,
|
x : body.position.x,
|
||||||
y : body.position.y
|
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;
|
} else {
|
||||||
position.y = tempPosition.y;
|
body.position.x = position.x;
|
||||||
|
body.position.y = position.y;
|
||||||
|
|
||||||
|
position.x = tempPosition.x;
|
||||||
|
position.y = tempPosition.y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.snake = snake;
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue