diff --git a/21g30t1e75.js b/21g30t1e75.js index 681417d..504fd38 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -1101,6 +1101,42 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { // body.applyToMesh(); //} if (!gameObject.isTail) { + + if (body.orientation !== backup.orientation) { + /** + * This head is bent + */ + body.applyToMesh(); + + body.backupMesh = body.mesh; + + if (body.orientation === GameLib.CustomCode.ORIENTATION_UP) { + body.backupMesh.position.y -= 0.5 * GameLib.CustomCode.BODY_SCALE_Y; + } + + if (body.orientation === GameLib.CustomCode.ORIENTATION_DOWN) { + body.backupMesh.position.y += 0.5 * GameLib.CustomCode.BODY_SCALE_Y; + } + + if (body.orientation === GameLib.CustomCode.ORIENTATION_LEFT) { + body.backupMesh.position.x += 0.5 * GameLib.CustomCode.BODY_SCALE_X; + } + + if (body.orientation === GameLib.CustomCode.ORIENTATION_RIGHT) { + body.backupMesh.position.x -= 0.5 * GameLib.CustomCode.BODY_SCALE_X; + } + + body.mesh = this.createGameMesh(this.materialBreadCorner); + + body.mesh.position.z = 5; + + body.mesh.updateInstance('position'); + + body.mesh.visible = true; + + body.mesh.updateInstance('visible'); + } + this.explode(body.position); } break;