Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 746 bytes modified
parent
2fff3a0272
commit
d7820f070b
|
@ -939,6 +939,10 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (this.state.eating === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
temp = {
|
temp = {
|
||||||
position : {
|
position : {
|
||||||
x : body.position.x,
|
x : body.position.x,
|
||||||
|
@ -948,26 +952,25 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
flip : body.flip
|
flip : body.flip
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.eating === false) {
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new empty object at the current grid position (free it up)
|
* Assign the new location to the body
|
||||||
*/
|
*/
|
||||||
this.grid[body.position.x][body.position.y] = new GameLib.CustomCode.GameObject();
|
body.position.x = backup.position.x;
|
||||||
|
body.position.y = backup.position.y;
|
||||||
|
body.orientation = backup.orientation;
|
||||||
|
body.flip = backup.flip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign the new location to the body
|
* Update the grid with our new body
|
||||||
*/
|
*/
|
||||||
body.position.x = backup.position.x;
|
this.grid[body.position.x][body.position.y] = body;
|
||||||
body.position.y = backup.position.y;
|
|
||||||
body.orientation = backup.orientation;
|
|
||||||
body.flip = backup.flip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the grid with our new body
|
|
||||||
*/
|
|
||||||
this.grid[body.position.x][body.position.y] = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body.backupMesh) {
|
if (body.backupMesh) {
|
||||||
/**
|
/**
|
||||||
|
@ -991,51 +994,42 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
body.mesh.updateInstance('position');
|
body.mesh.updateInstance('position');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backup.orientation !== temp.orientation) {
|
if (body.orientation !== temp.orientation) {
|
||||||
|
|
||||||
// if ((index ) < this.snake.length) {
|
body.orientation = temp.orientation;
|
||||||
/**
|
|
||||||
* Our orientation changed - we should make a corner
|
|
||||||
*/
|
|
||||||
body.orientation = temp.orientation;
|
|
||||||
|
|
||||||
body.applyToMesh();
|
body.applyToMesh();
|
||||||
|
|
||||||
body.orientation = backup.orientation;
|
body.orientation = backup.orientation;
|
||||||
|
|
||||||
body.backupMesh = body.mesh;
|
body.backupMesh = body.mesh;
|
||||||
|
|
||||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_UP) {
|
if (temp.orientation === GameLib.CustomCode.ORIENTATION_UP) {
|
||||||
body.backupMesh.position.y -= 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
body.backupMesh.position.y -= 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
if (temp.orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
||||||
body.backupMesh.position.y += 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
body.backupMesh.position.y += 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
if (temp.orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
||||||
body.backupMesh.position.x += 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
body.backupMesh.position.x += 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
if (temp.orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
||||||
body.backupMesh.position.x -= 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
body.backupMesh.position.x -= 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
//body.backupMesh.visible = false;
|
|
||||||
|
|
||||||
//body.backupMesh.updateInstance('visible');
|
body.mesh = this.createGameMesh(this.materialBreadCorner);
|
||||||
|
|
||||||
body.mesh = this.createGameMesh(this.materialBreadCorner);
|
body.mesh.position.z = 5;
|
||||||
|
|
||||||
body.mesh.position.z = 5;
|
body.mesh.updateInstance('position');
|
||||||
|
|
||||||
body.mesh.updateInstance('position');
|
body.mesh.visible = true;
|
||||||
|
|
||||||
body.mesh.visible = true;
|
|
||||||
|
|
||||||
body.mesh.updateInstance('visible');
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
body.mesh.updateInstance('visible');
|
||||||
}
|
}
|
||||||
|
|
||||||
backup = temp;
|
backup = temp;
|
||||||
|
|
Loading…
Reference in New Issue