From 561779f2bba516c324d4bcb6520d38f580c3775b Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Thu, 15 Mar 2018 13:16:43 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 588 bytes modified --- 21g30t1e75.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) 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; }