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