diff --git a/21g30t1e75.js b/21g30t1e75.js index 3ec99d2..80dcb2a 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -228,6 +228,7 @@ GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation) { GameLib.CustomCode.prototype.advanceSnake = function(delta) { + this.advanceTime += delta; if (this.advanceTime > this.speed) { @@ -249,14 +250,30 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { tail.position.y = parent.position.y; tail.orientation = parent.orientation; - if (this.snake.length === 1) { + if ( + this.snake.length === 1 && + this.state.turning && + parent.bodyType !== GameLib.CustomCode.BODY_TYPE_TAIL + ) { console.log('before head'); + + var corner = new GameLib.CustomCode.SnakeBody( + this.meshBreadCorner, + body.position, + body.orientation, + GameLib.CustomCode.BODY_TYPE_CORNER, + parent + ); + + this.state.turning = false; + + corner.applyToMesh(); + newSnake.unshift(corner); + } else { + tail.applyToMesh(); + newSnake.unshift(tail); } - - tail.applyToMesh(); - - newSnake.unshift(tail); - + tail = parent; }