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

beta.r3js.org
-=yb4f310 2018-03-12 21:25:43 +01:00
parent c89cab91cc
commit 22117eb8f8
1 changed files with 9 additions and 10 deletions

View File

@ -187,26 +187,20 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
var head = this.snake[0].clone();
head.advance();
this.snake = this.snake.reduce(
var snake = this.snake.reduce(
function(result, body, index) {
if ((index + 1) === this.snake.length) {
if ((index + 1) >= this.snake.length) {
/**
* we're done
*/
return result;
} else if ((index) === this.snake.length) {
/**
* Pop it
*/
this.snake[index].mesh.geometry = null;
this.snake[index].mesh.materials = null;
this.snake[index].mesh.remove();
} else {
/**
* Move the body over
*/
result.push(this.snake[index]);
result.push(this.snake[index + 1]);
}
return result;
@ -215,6 +209,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
[head]
)
var tail = this.snake.pop();
tail.mesh.geometry = null;
tail.mesh.materials = null;
tail.mesh.remove();
}.bind(this);
/*