diff --git a/21g30t1e75.js b/21g30t1e75.js index c9ab6d6..1b57725 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -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);