Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 252 bytes modified
parent
0f1b44d5f0
commit
8c6fd43435
102
21g30t1e75.js
102
21g30t1e75.js
|
@ -885,6 +885,44 @@ GameLib.CustomCode.prototype.powerup = function(gameObject) {
|
||||||
|
|
||||||
}.bind(this);
|
}.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
|
* Move the snake forward and do collision detection
|
||||||
* @type {function(this:snakeEntityLoaded)}
|
* @type {function(this:snakeEntityLoaded)}
|
||||||
|
@ -939,6 +977,11 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
break;
|
break;
|
||||||
case GameLib.CustomCode.OBJECT_TYPE_FOOD :
|
case GameLib.CustomCode.OBJECT_TYPE_FOOD :
|
||||||
this.extend(gameObject, backup.position, backup.orientation);
|
this.extend(gameObject, backup.position, backup.orientation);
|
||||||
|
|
||||||
|
if (backup.orientation !== body.orientation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GameLib.CustomCode.OBJECT_TYPE_POWERUP:
|
case GameLib.CustomCode.OBJECT_TYPE_POWERUP:
|
||||||
this.powerup(gameObject);
|
this.powerup(gameObject);
|
||||||
|
@ -955,11 +998,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (this.state.eating === true) {
|
temp = {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = {
|
|
||||||
position : {
|
position : {
|
||||||
x : body.position.x,
|
x : body.position.x,
|
||||||
y : body.position.y
|
y : body.position.y
|
||||||
|
@ -967,8 +1006,17 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
orientation : body.orientation,
|
orientation : body.orientation,
|
||||||
flip : body.flip
|
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)
|
* Create a new empty object at the current grid position (free it up)
|
||||||
*/
|
*/
|
||||||
|
@ -1009,44 +1057,10 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
body.mesh.updateInstance('position');
|
body.mesh.updateInstance('position');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.orientation !== temp.orientation) {
|
if (body.orientation !== temp.orientation) {
|
||||||
|
this.createCorner(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');
|
|
||||||
}
|
|
||||||
|
|
||||||
backup = temp;
|
backup = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue