From f2550aa3bd253cd58a7bebcaaad129557a7cbb7f Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Thu, 22 Mar 2018 19:10:45 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 438 bytes modified --- 21g30t1e75.js | 79 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index efda4bd..0752fb7 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -937,15 +937,8 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { } - } - - if (this.state.eating === true) { - body.applyToMesh(); - return; - } - - if (index > 0) { - + } else { + temp = { position : { x : body.position.x, @@ -955,49 +948,53 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { flip : body.flip } - /** - * Create a new empty object at the current grid position (free it up) - */ - this.grid[body.position.x][body.position.y] = new GameLib.CustomCode.GameObject(); + if (this.state.eating === false) { - /** - * Assign the new location to the body - */ - body.position.x = backup.position.x; - body.position.y = backup.position.y; - body.orientation = backup.orientation; - body.flip = backup.flip; + /** + * Create a new empty object at the current grid position (free it up) + */ + this.grid[body.position.x][body.position.y] = new GameLib.CustomCode.GameObject(); - /** - * Update the grid with our new body - */ - this.grid[body.position.x][body.position.y] = body; + /** + * Assign the new location to the body + */ + body.position.x = backup.position.x; + body.position.y = backup.position.y; + body.orientation = backup.orientation; + body.flip = backup.flip; - if (body.backupMesh) { - /** - * We used to be a corner, change back - * @type {null} - */ - body.mesh.geometry = null; + /** + * Update the grid with our new body + */ + this.grid[body.position.x][body.position.y] = body; - body.mesh.materials = null; + if (body.backupMesh) { + /** + * We used to be a corner, change back + * @type {null} + */ + body.mesh.geometry = null; - body.mesh.remove(); + body.mesh.materials = null; - body.mesh = body.backupMesh; + body.mesh.remove(); - body.backupMesh = null; + body.mesh = body.backupMesh; - body.mesh.visible = true; + body.backupMesh = null; - body.mesh.updateInstance('visible'); + body.mesh.visible = true; - body.mesh.updateInstance('position'); - } + body.mesh.updateInstance('visible'); - if (body.orientation !== temp.orientation) { + body.mesh.updateInstance('position'); + } - if ((index ) < this.snake.length) { + } + + if (backup.orientation !== temp.orientation) { + + // if ((index ) < this.snake.length) { /** * Our orientation changed - we should make a corner */ @@ -1038,7 +1035,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { body.mesh.visible = true; body.mesh.updateInstance('visible'); - } + //} }