From 0b72479c81abe04fa334ba0b736c7aa95532e27e Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 24 Mar 2018 11:15:13 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 65 bytes modified --- 21g30t1e75.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index c213fec..d032d70 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -243,7 +243,7 @@ GameLib.CustomCode.prototype.waitReload = function(delta) { }.bind(this), 5000 ); - + window.setTimeout( function(){ this.state.message = "GO!"; @@ -833,7 +833,9 @@ GameLib.CustomCode.SnakeBody.prototype = Object.create(GameLib.CustomCode.GameOb GameLib.CustomCode.SnakeBody.prototype.constructor = GameLib.CustomCode.GameObject; GameLib.CustomCode.SnakeBody.prototype.dispose = function() { + GameLib.CustomCode.GameObject.prototype.dispose.call(this); + if (this.backupMesh) { this.backupMesh.geometry = null; this.backupMesh.materials = null; @@ -1152,7 +1154,7 @@ GameLib.CustomCode.prototype.createCorner = function(body, temp) { GameLib.CustomCode.prototype.backup = function() { - this.backup = { + this.backupState = { snake : this.snake.map( function(body) { return body.clone(); @@ -1178,7 +1180,7 @@ GameLib.CustomCode.prototype.restore = function() { var meshFound = false; var backupMeshFound = false; - this.backup.snake.map( + this.backupState.snake.map( function (backupBody) { if ( body.mesh === backupBody.mesh || @@ -1222,15 +1224,15 @@ GameLib.CustomCode.prototype.restore = function() { /** * Restore our backup */ - this.state.orientation = this.backup.orientation; - this.state.flip = this.backup.flip; - this.snake = this.backup.snake.map( + this.state.orientation = this.backupState.orientation; + this.state.flip = this.backupState.flip; + this.snake = this.backupState.snake.map( function(body) { - + var clone = body.clone(); - + clone.applyToMesh(); - + return clone; }.bind(this) ); @@ -1287,7 +1289,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { body.mesh.updateInstance('position'); } - + if (index === 0) { backup = { @@ -1308,11 +1310,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { this.grid[backup.position.x][backup.position.y] = new GameLib.CustomCode.GameObject(); if (!advanced) { - + this.explode(body.position); } else { - + var gameObject = this.grid[body.position.x][body.position.y]; switch (gameObject.objectType) {