From df847e3fe25d7ff198934b3589899a9e2c566edd Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 19 Mar 2018 10:08:33 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 163 bytes modified --- 21g30t1e75.js | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index bec89ae..58e29cf 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -167,8 +167,8 @@ GameLib.CustomCode.SnakeBody = function( backupMesh = null; } this.backupMesh = backupMesh; - - this.applyToMesh(flip); + + this.applyToMesh(); }; // GameLib.CustomCode.SnakeBody.prototype.restoreBackup = function() { @@ -195,7 +195,7 @@ GameLib.CustomCode.SnakeBody = function( // */ // } -GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function(flip) { +GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function() { this.mesh.position.x = this.position.x + GameLib.CustomCode.GRID_OFFSET_X; this.mesh.position.y = this.position.y + GameLib.CustomCode.GRID_OFFSET_Y; @@ -203,7 +203,7 @@ GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function(flip) { this.mesh.rotation.z = this.orientation * Math.PI / 2; if (this.backupMesh) { - this.mesh.rotation.z += ((Math.PI / 2) * flip); + this.mesh.rotation.z += ((Math.PI / 2) * this.flip); } /** @@ -213,7 +213,7 @@ GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function(flip) { this.mesh.updateInstance('rotation'); } -GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation) { +GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation, flip) { if (orientation === GameLib.CustomCode.ORIENTATION_UP) { this.position.y += 1; @@ -232,6 +232,8 @@ GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation) { } this.orientation = orientation; + + this.flip = flip; } GameLib.CustomCode.prototype.advanceSnake = function(delta) { @@ -258,14 +260,17 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { x : body.position.x, y : body.position.y }, - orientation : body.orientation + orientation : body.orientation, + flip : body.flip } body.advance( - this.state.orientation + this.state.orientation, + this.state.flip ); - backup.orientation = body.orientation; + backup.orientation = body.orientation; + backup.flip = body.flip; } if (index > 0) { @@ -275,15 +280,17 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { x : body.position.x, y : body.position.y }, - orientation : body.orientation + orientation : body.orientation, + flip : body.flip } body.position.x = backup.position.x; body.position.y = backup.position.y; body.orientation = backup.orientation; + body.flip = backup.flip; backup = temp; - + if (body.backupMesh) { /** * We used to be a corner, change back @@ -319,14 +326,14 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { body.backupMesh.updateInstance('visible'); body.mesh = this.meshBreadCorner.clone(); - } - - //body.orientation = this.snake[index - 1].orientation; - - } + } + + //body.orientation = this.snake[index - 1].orientation; + + } } - body.applyToMesh(this.state.flip); + body.applyToMesh(); }.bind(this) ) @@ -415,11 +422,11 @@ GameLib.Event.Subscribe( this.grid.map( function(x) { x.map( - function(y) { - y.mesh.geometry = null; - y.mesh.materials = null; - y.mesh.remove(); - } +function(y) { + y.mesh.geometry = null; + y.mesh.materials = null; + y.mesh.remove(); +} ); } );