diff --git a/21g30t1e75.js b/21g30t1e75.js index 9f45168..f7c07a2 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -134,7 +134,7 @@ this.state = { orientation : 0, turning : false, flip : 0, - eating : false + eating : 0 }; GameLib.CustomCode.prototype.visualizeGrid = function () { @@ -726,52 +726,6 @@ GameLib.CustomCode.prototype.initializeGrid = function() { }.bind(this); -// GameLib.CustomCode.prototype.rebuildGrid = function() { -// -// this.initializeGrid(); -// -// /** -// * First add all the snake body parts -// */ -// this.snake.map( -// function(body, index) { -// this.grid[body.position.x][body.position.y] = { -// occupied: true, -// type : GameLib.CustomCode.OBJECT_TYPE_SNAKE_BODY, -// index : index -// } -// }.bind(this) -// ); -// -// /** -// * Then add all the food bits -// */ -// this.food.map( -// function(food, index) { -// this.grid[food.position.x][food.position.y] = { -// occupied: true, -// type : GameLib.CustomCode.OBJECT_TYPE_FOOD, -// index : index -// } -// }.bind(this) -// ); -// -// /** -// * And also all the power ups -// */ -// this.powerups.map( -// function(powerup, index) { -// this.grid[powerup.position.x][powerup.position.y] = { -// occupied: true, -// type : GameLib.CustomCode.OBJECT_TYPE_POWERUP, -// index : index -// } -// }.bind(this) -// ); -// -// }.bind(this); - - /** * Explode the snake * @param position @@ -869,7 +823,7 @@ GameLib.CustomCode.prototype.extend = function(gameObject, position, orientation body.mesh.updateInstance('position'); - this.state.eating = true; + this.state.eating = 2; this.snake.splice(1, 0, body); @@ -977,7 +931,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { backup.flip = body.flip; } - if (this.state.eating) { + if (this.state.eating > 0) { return } @@ -1082,16 +1036,13 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { backup = temp; } - //if (!body.isTail) { - body.applyToMesh(); - //} }.bind(this) ) this.state.turning = false; - this.state.eating = false; + this.state.eating -= 1; this.visualizeGrid();