Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 164 bytes modified
parent
659e69ef09
commit
5b86265f47
|
@ -187,35 +187,24 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
var head = this.snake[0].clone();
|
var head = this.snake[0].clone();
|
||||||
head.advance();
|
head.advance();
|
||||||
|
|
||||||
var snake = this.snake.reduce(
|
var oldHead = this.snake.shift();
|
||||||
function(result, body, index) {
|
oldHead.mesh.geometry = null;
|
||||||
|
oldHead.mesh.materials = null;
|
||||||
if ((index + 1) >= this.snake.length) {
|
oldHead.mesh.remove();
|
||||||
/**
|
|
||||||
* we're done
|
|
||||||
*/
|
|
||||||
return result;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/**
|
|
||||||
* Move the body over
|
|
||||||
*/
|
|
||||||
result.push(this.snake[index + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}.bind(this),
|
|
||||||
[head]
|
|
||||||
)
|
|
||||||
|
|
||||||
var tail = this.snake.pop();
|
var oldTail = this.snake.pop();
|
||||||
tail.mesh.geometry = null;
|
|
||||||
tail.mesh.materials = null;
|
|
||||||
tail.mesh.remove();
|
|
||||||
|
|
||||||
this.snake = snake;
|
var snake = [head];
|
||||||
|
|
||||||
|
this.snake.map(
|
||||||
|
function(body) {
|
||||||
|
snake.push(body);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
snake.push(oldTail);
|
||||||
|
|
||||||
|
this.snake = snake;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue