diff --git a/21g30t1e75.js b/21g30t1e75.js index 59b0dd9..8f309fe 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -232,20 +232,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { } else { - if ( - index === 1 && - this.state.turning && - body.bodyType !== GameLib.CustomCode.BODY_TYPE_TAIL - ) { - - body.backupMesh = body.mesh; - - body.mesh = this.meshBreadCorner.clone(); - - body.bodyType = GameLib.CustomCode.BODY_TYPE_CORNER; - - this.state.turning = false; - } + var temp = { x : body.position.x, @@ -257,8 +244,31 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { body.position.x = backup.x; body.position.y = backup.y; body.orientation = backup.orientation; - body.bodyType = backup.bodyType; - + + if ( + index === 1 && + this.state.turning && + body.bodyType !== GameLib.CustomCode.BODY_TYPE_TAIL + ) { + + body.backupMesh = body.mesh; + + body.backupMesh.visible = false; + + body.backupMesh.updateInstance('visible'); + + body.mesh = this.meshBreadCorner.clone(); + + body.bodyType = GameLib.CustomCode.BODY_TYPE_CORNER; + + this.state.turning = false; + + } else { + + body.bodyType = backup.bodyType; + + } + backup.x = temp.x; backup.y = temp.y; backup.orientation = temp.orientation;