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

beta.r3js.org
-=yb4f310 2018-03-15 13:12:13 +01:00
parent 42b802d7f0
commit 374ee2c16a
1 changed files with 41 additions and 37 deletions

View File

@ -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(