Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 275 bytes modified
parent
42b802d7f0
commit
374ee2c16a
|
@ -228,45 +228,49 @@ GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation) {
|
|||
|
||||
GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||
|
||||
this.advanceTime += delta;
|
||||
this.advanceTime += delta;
|
||||
|
||||
if (this.advanceTime > this.speed) {
|
||||
this.advanceTime = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var tail = this.snake.pop();
|
||||
var parent = null;
|
||||
|
||||
var newSnake = [];
|
||||
|
||||
while (this.snake.length > 0) {
|
||||
|
||||
parent = this.snake.pop();
|
||||
|
||||
tail.position.x = parent.position.x;
|
||||
tail.position.y = parent.position.y;
|
||||
tail.orientation = parent.orientation;
|
||||
|
||||
if (this.snake.length === 1) {
|
||||
console.log('before head');
|
||||
}
|
||||
|
||||
tail.applyToMesh();
|
||||
|
||||
newSnake.unshift(tail);
|
||||
|
||||
tail = parent;
|
||||
}
|
||||
|
||||
tail.advance(
|
||||
this.state.orientation
|
||||
);
|
||||
|
||||
tail.applyToMesh();
|
||||
|
||||
newSnake.unshift(tail);
|
||||
|
||||
this.snake = newSnake;
|
||||
|
||||
if (this.advanceTime > this.speed) {
|
||||
this.advanceTime = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var tail = this.snake.pop();
|
||||
var parent = null;
|
||||
|
||||
var newSnake = [];
|
||||
|
||||
while (this.snake.length > 0) {
|
||||
|
||||
parent = this.snake.pop();
|
||||
|
||||
tail.position.x = parent.position.x;
|
||||
tail.position.y = parent.position.y;
|
||||
tail.orientation = parent.orientation;
|
||||
|
||||
tail.applyToMesh();
|
||||
|
||||
newSnake.unshift(tail);
|
||||
|
||||
tail = parent;
|
||||
}
|
||||
|
||||
tail.advance(
|
||||
this.state.orientation
|
||||
);
|
||||
|
||||
tail.applyToMesh();
|
||||
|
||||
newSnake.unshift(tail);
|
||||
|
||||
this.snake = newSnake;
|
||||
|
||||
return;
|
||||
|
||||
this.snake = this.snake.map(
|
||||
|
||||
|
|
Loading…
Reference in New Issue