diff --git a/21g30t1e75.js b/21g30t1e75.js index eb469fa..d9c01e6 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -252,7 +252,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { }, orientation : body.orientation } - + body.advance( this.state.orientation ); @@ -267,20 +267,51 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { }, orientation : body.orientation } - + body.position.x = backup.position.x; body.position.y = backup.position.y; body.orientation = backup.orientation; + 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.mesh.visible = true; + + body.mesh.updateInstance('visible'); + } + + if (body.orientation !== temp.orientation) { + /** + * Our orientation changed - we should make a corner + */ + body.backupMesh = body.mesh; + + body.backupMesh.visible = false; + + body.backupMesh.updateInstance('visible'); + + body.mesh = this.meshBreadCorner.clone(); + } + backup = temp; } - + body.applyToMesh(); }.bind(this) ) - return; + }.bind(this); /*