Commit 5e9662ab authored by Matthew Odle's avatar Matthew Odle

move centipede-specific logic out of canvas-libs

parent 85a3bf74
......@@ -95,7 +95,7 @@ var centipedes = {
this.centipedes.map(centipede => centipede.updated = false);
},
moveDownwardInitially : function(centipede) {
if (centipede.y < game.gameArea.firstMushroomLayer - 1) {
if (centipede.y < game.gameArea.gridStart - 1) {
centipede.moveVertically = true;
centipede.updated = true;
};
......
......@@ -85,7 +85,7 @@ var gameObjects = {
};
},
dropMushrooms : function(creature) {
if (this.eligibleToDrop() && creature.y <= game.gameArea.canvas.height * 0.90 && creature.y >= game.gameArea.firstMushroomLayer) {
if (this.eligibleToDrop() && creature.y <= game.gameArea.canvas.height * 0.90 && creature.y >= game.gameArea.gridStart) {
mushrooms.make({x : creature.x, y : creature.y});
};
},
......
......@@ -16,4 +16,7 @@ players = {
this.boundaries.insideLeft = player.getLeft() > 0;
},
},
collidedWithBarrier : function(player) {
return collisions.withMushrooms(player);
},
};
......@@ -4,4 +4,20 @@ var game = {
this.gameArea.init(knobsAndLevers);
console.log('game initialized');
},
gameResets : {
level : function() {
centipedes.clear();
},
death : function() {
centipedes.clear();
lasers.clear();
},
everything : function() {
mushrooms.clear();
init.afterGameOver();
},
},
gameLevelCheck : function() {
return centipedes.numberSpawned == centipedes.numberKilled && this.gameArea.frameNo;
},
};
......@@ -99,7 +99,7 @@ describe('CENTIPEDES SPEC: ', () => {
spyOn(testObj, 'reverseHorizontalAtNextLayer');
testObj.centipedes = [
{moveVertically : false, updated : false, y : game.gameArea.firstMushroomLayer - 2},
{moveVertically : false, updated : false, y : game.gameArea.gridStart - 2},
];
testObj.determineDirections();
......@@ -122,9 +122,9 @@ describe('CENTIPEDES SPEC: ', () => {
knobsAndLevers.init();
game.init();
testObj.centipedes = [
{moveVertically : false, updated : false, y : game.gameArea.firstMushroomLayer - 2},
{moveVertically : false, updated : true, y : game.gameArea.firstMushroomLayer - 2},
{moveVertically : false, updated : false, y : game.gameArea.firstMushroomLayer},
{moveVertically : false, updated : false, y : game.gameArea.gridStart - 2},
{moveVertically : false, updated : true, y : game.gameArea.gridStart - 2},
{moveVertically : false, updated : false, y : game.gameArea.gridStart},
];
testObj.centipedes.filter(centipede => !centipede.updated).map(centipede => {
......@@ -306,7 +306,7 @@ describe('CENTIPEDES SPEC: ', () => {
},
{
crashWith : crashWith,
y : game.gameArea.firstMushroomLayer,
y : game.gameArea.gridStart,
distanceMovedX : distanceMovedX,
moveVertically : moveVertically,
expected : false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment