Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 538 bytes modified
parent
c812a1f522
commit
fdc8eb81f5
|
@ -237,24 +237,43 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
var backup = null;
|
||||
var temp = null;
|
||||
|
||||
this.snake.map(
|
||||
function(body, index) {
|
||||
|
||||
if (index === 0) {
|
||||
|
||||
backup = {
|
||||
position : {
|
||||
x : body.position.x,
|
||||
y : body.position.y
|
||||
},
|
||||
orientation : body.orientation
|
||||
}
|
||||
|
||||
body.advance(
|
||||
this.state.orientation
|
||||
);
|
||||
}
|
||||
|
||||
if (index + 1 <= this.snake.length) {
|
||||
|
||||
this.snake[index+1].orientation = body.orientation;
|
||||
this.snake[index+1].position.x = body.position.x;
|
||||
this.snake[index+1].position.y = body.position.y;
|
||||
|
||||
if (index > 0) {
|
||||
|
||||
temp = {
|
||||
position : {
|
||||
x : body.position.x,
|
||||
y : body.position.y
|
||||
},
|
||||
orientation : body.orientation
|
||||
}
|
||||
|
||||
body.position.x = backup.position.x;
|
||||
body.position.y = backup.position.y;
|
||||
body.orientation = backup.orientation;
|
||||
|
||||
backup = temp;
|
||||
}
|
||||
|
||||
body.applyToMesh();
|
||||
|
||||
|
|
Loading…
Reference in New Issue