Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 4063 bytes modified
parent
02e5d40445
commit
1f0b599d61
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue