Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 1387 bytes modified

beta.r3js.org
-=yb4f310 2018-03-24 11:10:06 +01:00
parent 4956323ad7
commit 40311bb233
1 changed files with 123 additions and 193 deletions

View File

@ -157,8 +157,7 @@ this.state = {
exploding : false,
lives : 3,
getReady : false,
message : null,
overrideOrientation : false
message : null
};
GameLib.CustomCode.prototype.displayHUD = function() {
@ -237,8 +236,6 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
this.state.getReady = true;
this.advanceSnake(this.speed * 2);
window.setTimeout(
function(){
this.state.message = null;
@ -247,7 +244,6 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
5000
);
window.setTimeout(
function(){
this.state.message = "GO!";
@ -289,8 +285,6 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
GameLib.CustomCode.prototype.visualizeGrid = function () {
return;
if (this.noneMesh) {
this.scene.instance.remove(this.noneMesh);
}
@ -1158,34 +1152,15 @@ GameLib.CustomCode.prototype.createCorner = function(body, temp) {
GameLib.CustomCode.prototype.backup = function() {
if (GameLib.Utils.UndefinedOrNull(this.backupSnake)) {
this.backupSnake = this.snake.map(
this.backup = {
snake : this.snake.map(
function(body) {
return body.clone();
}
);
this.backupOrientation = this.state.orientation;
}
this.backupPrevious = this.backupSnake.map(
function(body) {
return body.clone();
}
);
this.backupSnake = this.snake.map(
function(body) {
return body.clone();
}
);
this.backupPreviousOrientation = this.backupOrientation;
this.backupOrientation = this.state.orientation;
this.state.overrideOrientation = true;
),
orientation : this.state.orientation,
flip : this.state.flip
};
}.bind(this)
@ -1203,7 +1178,7 @@ GameLib.CustomCode.prototype.restore = function() {
var meshFound = false;
var backupMeshFound = false;
this.backupPrevious.map(
this.backup.snake.map(
function (backupBody) {
if (
body.mesh === backupBody.mesh ||
@ -1245,18 +1220,21 @@ GameLib.CustomCode.prototype.restore = function() {
this.initializeGrid();
/**
* Restore our backup snake
* Restore our backup
*/
this.snake = this.backupPrevious.map(
this.state.orientation = this.backup.orientation;
this.state.flip = this.backup.flip;
this.snake = this.backup.snake.map(
function(body) {
return body.clone();
var clone = body.clone();
clone.applyToMesh();
return clone;
}.bind(this)
);
this.state.orientation = this.backupPreviousOrientation;
this.backupSnake = null;
this.backup();
this.visualizeGrid();
@ -1288,8 +1266,6 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
this.snake.map(
function(body, index) {
if (index === 0) {
if (body.backupMesh) {
/**
* We used to be a corner, change back
@ -1312,6 +1288,8 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
body.mesh.updateInstance('position');
}
if (index === 0) {
backup = {
position : {
x : body.position.x,
@ -1331,41 +1309,15 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
if (!advanced) {
if (this.state.getReady) {
body.position.x = backup.position.x;
body.position.y = backup.position.y;
body.orientation = backup.orientation;
body.flip = backup.flip;
body.applyToMesh();
return;
}
this.explode(body.position);
} else {
if (this.state.overrideOrientation) {
this.backupPreviousOrientation = this.state.orientation;
this.backupOrientation = this.state.orientation;
this.state.overrideOrientation = false;
}
var gameObject = this.grid[body.position.x][body.position.y];
switch (gameObject.objectType) {
case GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY :
//f (body.orientation !== backup.orientation) {
//body.orientation = backup.orientation;
//body.flip = backup.flip;
//backup.orientation = this.state.orientation;
//backup.flip = this.state.flip;
// this.createCorner(body, backup);
// body.applyToMesh();
//}
if (!gameObject.isTail) {
if (body.orientation !== backup.orientation) {
@ -1487,28 +1439,6 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
*/
this.grid[body.position.x][body.position.y] = body;
if (body.backupMesh) {
/**
* We used to be a corner, change back
* @type {null}
*/
body.mesh.geometry = null;
body.mesh.materials = null;
body.mesh.remove();
body.mesh = body.backupMesh;
body.backupMesh = null;
body.mesh.visible = true;
body.mesh.updateInstance('visible');
body.mesh.updateInstance('position');
}
if (body.orientation !== temp.orientation) {
this.createCorner(body, temp);
}