diff --git a/21g30t1e75.js b/21g30t1e75.js index c3bde93..c6f68ae 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -1036,6 +1036,28 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { if (index === 0) { + if (body.backupMesh) { + /** + * We used to be a corner, change back + * @type {null} + */ + body.mesh.geometry = null; + + body.mesh.materials = null; + + body.mesh.remove(); + + body.mesh = body.backupMesh; + + body.backupMesh = null; + + body.mesh.visible = true; + + body.mesh.updateInstance('visible'); + + body.mesh.updateInstance('position'); + } + backup = { position : { x : body.position.x, @@ -1063,6 +1085,16 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { switch (gameObject.objectType) { case GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY : + + if (body.orientation !== backup.orientation) { + body.orientation = backup.orientation; + body.flip = backup.flip; + backup.orientation = this.state.orientation; + backup.flip = this.state.flip; + this.createCorner(body, backup); + body.applyToMesh(); + } + this.explode(body.position); break; case GameLib.CustomCode.OBJECT_TYPE_FOOD :