Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 252 bytes modified
parent
0f1b44d5f0
commit
8c6fd43435
|
@ -885,6 +885,44 @@ GameLib.CustomCode.prototype.powerup = function(gameObject) {
|
|||
|
||||
}.bind(this);
|
||||
|
||||
GameLib.CustomCode.prototype.createCorner = function(body, temp) {
|
||||
|
||||
body.orientation = temp.orientation;
|
||||
|
||||
body.applyToMesh();
|
||||
|
||||
body.orientation = backup.orientation;
|
||||
|
||||
body.backupMesh = body.mesh;
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_UP) {
|
||||
body.backupMesh.position.y -= 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
||||
body.backupMesh.position.y += 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
||||
body.backupMesh.position.x += 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
||||
body.backupMesh.position.x -= 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||
}
|
||||
|
||||
body.mesh = this.createGameMesh(this.materialBreadCorner);
|
||||
|
||||
body.mesh.position.z = 5;
|
||||
|
||||
body.mesh.updateInstance('position');
|
||||
|
||||
body.mesh.visible = true;
|
||||
|
||||
body.mesh.updateInstance('visible');
|
||||
|
||||
}.bind(this);
|
||||
|
||||
/**
|
||||
* Move the snake forward and do collision detection
|
||||
* @type {function(this:snakeEntityLoaded)}
|
||||
|
@ -939,6 +977,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
break;
|
||||
case GameLib.CustomCode.OBJECT_TYPE_FOOD :
|
||||
this.extend(gameObject, backup.position, backup.orientation);
|
||||
|
||||
if (backup.orientation !== body.orientation) {
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case GameLib.CustomCode.OBJECT_TYPE_POWERUP:
|
||||
this.powerup(gameObject);
|
||||
|
@ -955,11 +998,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
|
||||
} else {
|
||||
|
||||
if (this.state.eating === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
temp = {
|
||||
temp = {
|
||||
position : {
|
||||
x : body.position.x,
|
||||
y : body.position.y
|
||||
|
@ -968,6 +1007,15 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
flip : body.flip
|
||||
}
|
||||
|
||||
if (this.state.eating === true) {
|
||||
|
||||
if ((body.orientation !== temp.orientation) &&
|
||||
(index === 1)) {
|
||||
this.createCorner(body, temp);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new empty object at the current grid position (free it up)
|
||||
|
@ -1009,43 +1057,9 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
body.mesh.updateInstance('position');
|
||||
}
|
||||
|
||||
if (body.orientation !== temp.orientation) {
|
||||
|
||||
body.orientation = temp.orientation;
|
||||
|
||||
body.applyToMesh();
|
||||
|
||||
body.orientation = backup.orientation;
|
||||
|
||||
body.backupMesh = body.mesh;
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_UP) {
|
||||
body.backupMesh.position.y -= 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
||||
body.backupMesh.position.y += 0.5 * GameLib.CustomCode.BODY_SCALE_Y;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
||||
body.backupMesh.position.x += 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||
}
|
||||
|
||||
if (temp.orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
||||
body.backupMesh.position.x -= 0.5 * GameLib.CustomCode.BODY_SCALE_X;
|
||||
}
|
||||
|
||||
|
||||
body.mesh = this.createGameMesh(this.materialBreadCorner);
|
||||
|
||||
body.mesh.position.z = 5;
|
||||
|
||||
body.mesh.updateInstance('position');
|
||||
|
||||
body.mesh.visible = true;
|
||||
|
||||
body.mesh.updateInstance('visible');
|
||||
}
|
||||
if (body.orientation !== temp.orientation) {
|
||||
this.createCorner(body, temp);
|
||||
}
|
||||
|
||||
backup = temp;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue