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

beta.r3js.org
-=yb4f310 2018-03-19 08:35:53 +01:00
parent 8876d30a3f
commit 5f5429f814
1 changed files with 14 additions and 7 deletions

View File

@ -128,13 +128,15 @@ this.meshPatty = this.createGameMesh(this.imagePatty);
* @param position
* @param orientation
* @param flip
* @param backupMesh
* @constructor
*/
GameLib.CustomCode.SnakeBody = function(
mesh,
position,
orientation,
flip
flip,
backupMesh
) {
if (GameLib.Utils.UndefinedOrNull(mesh)) {
@ -155,12 +157,17 @@ GameLib.CustomCode.SnakeBody = function(
orientation = GameLib.CustomCode.ORIENTATION_UP;
}
this.orientation = orientation;
if (GameLib.Utils.UndefinedOrNull(flip)) {
flip = false;
}
this.flip = flip;
if (GameLib.Utils.UndefinedOrNull(backupMesh)) {
backupMesh = null;
}
this.backupMesh = backupMesh;
this.applyToMesh(flip);
};
@ -194,11 +201,11 @@ GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function(flip) {
this.mesh.position.y = this.position.y + GameLib.CustomCode.GRID_OFFSET_Y;
this.mesh.rotation.z = this.orientation * Math.PI / 2;
if (flip) {
if (this.backupMesh && flip) {
this.mesh.rotation.z += Math.PI / 2;
}
/**
* TODO: We don't update instance position - animation should do this
*/
@ -275,6 +282,8 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
body.position.y = backup.position.y;
body.orientation = backup.orientation;
backup = temp;
if (body.backupMesh) {
/**
* We used to be a corner, change back
@ -314,8 +323,6 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
body.orientation = this.snake[index - 1].orientation;
}
}
backup = temp;
}
body.applyToMesh(this.state.flip);