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

beta.r3js.org
-=yb4f310 2018-03-22 12:31:24 +01:00
parent 02e5d40445
commit 1f0b599d61
1 changed files with 983 additions and 960 deletions

View File

@ -778,9 +778,32 @@ GameLib.CustomCode.prototype.explode = function(position) {
* Extend the snake with information from gameObject
* @param gameObject
*/
GameLib.CustomCode.prototype.extend = function(gameObject) {
console.log('extend');
};
GameLib.CustomCode.prototype.extend = function(gameObject, position, orientation) {
if (gameObject.objectType !== GameLib.CustomCode.OBJECT_TYPE_FOOD) {
throw new Error('wrong type of game object');
}
var body = null;
switch (gameObject.type) {
case GameLib.CustomCode.FOOD_BACON :
body = this.createGameObject(
GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY,
GameLib.CustomCode.BODY_TYPE_BREAD_BACON,
position,
orientation
)
break;
default :
throw new Error('unhandled food type: ' + gameObject.type);
}
this.state.eating = true;
this.snake.splice(1, 0, body);
}.bind(this);
/**
* Powerup the snake with information from gameObject