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

beta.r3js.org
-=yb4f310 2018-03-15 15:12:26 +01:00
parent c812a1f522
commit fdc8eb81f5
1 changed files with 28 additions and 9 deletions

View File

@ -237,30 +237,49 @@ 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) {
if (index > 0) {
temp = {
position : {
x : body.position.x,
y : body.position.y
},
orientation : body.orientation
}
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;
body.position.x = backup.position.x;
body.position.y = backup.position.y;
body.orientation = backup.orientation;
backup = temp;
}
body.applyToMesh();
}.bind(this)
)
return;
}.bind(this);