Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 86 bytes modified
parent
c89cab91cc
commit
22117eb8f8
|
@ -187,26 +187,20 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
var head = this.snake[0].clone();
|
var head = this.snake[0].clone();
|
||||||
head.advance();
|
head.advance();
|
||||||
|
|
||||||
this.snake = this.snake.reduce(
|
var snake = this.snake.reduce(
|
||||||
function(result, body, index) {
|
function(result, body, index) {
|
||||||
|
|
||||||
if ((index + 1) === this.snake.length) {
|
if ((index + 1) >= this.snake.length) {
|
||||||
/**
|
/**
|
||||||
* we're done
|
* we're done
|
||||||
*/
|
*/
|
||||||
return result;
|
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 {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Move the body over
|
* Move the body over
|
||||||
*/
|
*/
|
||||||
result.push(this.snake[index]);
|
result.push(this.snake[index + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -215,6 +209,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
[head]
|
[head]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var tail = this.snake.pop();
|
||||||
|
tail.mesh.geometry = null;
|
||||||
|
tail.mesh.materials = null;
|
||||||
|
tail.mesh.remove();
|
||||||
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue