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

beta.r3js.org
-=yb4f310 2018-03-22 18:33:24 +01:00
parent 730d92b7c3
commit d7c1739d11
1 changed files with 26 additions and 24 deletions

View File

@ -915,6 +915,32 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
backup.orientation = body.orientation;
backup.flip = body.flip;
if (!advanced) {
this.explode(body.position);
} else {
var gameObject = this.grid[body.position.x][body.position.y];
switch (gameObject.objectType) {
case GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY :
this.explode(body.position);
break;
case GameLib.CustomCode.OBJECT_TYPE_FOOD :
this.extend(gameObject, body.position, body.orientation);
break;
case GameLib.CustomCode.OBJECT_TYPE_POWERUP:
this.powerup(gameObject);
break;
default:
this.grid[body.position.x][body.position.y] = body;
break;
}
}
}
if (this.state.eating === true) {
@ -1032,31 +1058,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
this.state.eating = false;
var head = this.snake[0];
if (!advanced) {
this.explode(head.position);
} else {
var gameObject = this.grid[head.position.x][head.position.y];
switch (gameObject.objectType) {
case GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY :
this.explode(head.position);
break;
case GameLib.CustomCode.OBJECT_TYPE_FOOD :
this.extend(gameObject, head.position, head.orientation);
break;
case GameLib.CustomCode.OBJECT_TYPE_POWERUP:
this.powerup(gameObject);
break;
default:
this.grid[head.position.x][head.position.y] = head;
break;
}
}
this.visualizeGrid();