Commit 85a3bf74 authored by Matthew Odle's avatar Matthew Odle

rename spider to spiders

parent b024864e
......@@ -18,7 +18,7 @@ var collisions = {
targets.push(...centipedes.centipedes);
targets.push(...gameObjects.worms);
targets.push(...gameObjects.flies);
targets.push(...gameObjects.spider);
targets.push(...gameObjects.spiders);
return targets;
},
checkLaser : function(player, targets) {
......@@ -73,6 +73,7 @@ var collisions = {
targets = [];
targets.push(...centipedes.centipedes);
targets.push(...gameObjects.flies);
targets.push(...gameObjects.spiders);
return targets;
},
checkPlayerVsEnemies : function(player, targets) {
......@@ -102,6 +103,6 @@ var collisions = {
centipedes.centipedes = centipedes.centipedes.filter(centipede => centipede.hitPoints > 0);
gameObjects.worms = gameObjects.worms.filter(worm => worm.hitPoints > 0);
gameObjects.flies = gameObjects.flies.filter(fly => fly.hitPoints > 0);
gameObjects.spider = gameObjects.spider.filter(spider => spider.hitPoints > 0);
gameObjects.spiders = gameObjects.spiders.filter(spider => spider.hitPoints > 0);
},
};
......@@ -2,12 +2,12 @@
var gameObjects = {
worms : [],
flies : [],
spider : [],
spiders : [],
init : function() {
this.intervals = {
flies : knobsAndLevers.flies.initialInterval,
worms : knobsAndLevers.worms.initialInterval,
spider : knobsAndLevers.spider.initialInterval,
spiders : knobsAndLevers.spiders.initialInterval,
};
console.log('gameObjects initialized');
},
......@@ -57,25 +57,23 @@ var gameObjects = {
},
update : function(type) {
this[type].forEach(creature => {
if (type == 'spider') {
this.setSpeed(creature);
if (type == 'spiders') {
this.setSpeed(creature, type);
this.setDirection(creature);
this.removeMushrooms(creature);
};
creature.newPos();
creature.update();
if (type == 'flies') {
this.dropMushrooms(creature);
};
if (type == 'spider') {
this.removeMushrooms(creature);
};
if (type == 'worms') {
this.changeMushrooms(creature);
};
creature.newPos();
creature.update();
});
},
setSpeed : function(creature) {
let speedLimits = knobsAndLevers[creature.type].speedLimits;
setSpeed : function(creature, type) {
let speedLimits = knobsAndLevers[type].speedLimits;
creature.speedX = Math.sign(creature.speedX) * (supporting.roll(10).crit ? speedLimits.max : speedLimits.min);
creature.speedY = creature.directionY * (supporting.roll(10).crit ? speedLimits.max : speedLimits.min);
},
......@@ -115,5 +113,6 @@ var gameObjects = {
clear : function() {
this.worms = [];
this.flies = [];
this.spiders = [];
},
};
......@@ -15,7 +15,6 @@ var init = {
metrics.init();
players.init();
sounds.init();
spiders.init();
texts.init();
console.log("centipede game initialized");
......@@ -25,7 +24,6 @@ var init = {
knobsAndLevers.init();
menus.init();
metrics.init();
spiders.init();
texts.init();
gameObjects.init();
game.paused = true;
......
......@@ -43,7 +43,6 @@ var scripts = [
'components/mushrooms.js',
'components/players.js',
'components/texts.js',
'components/spiders.js',
'game.js',
'init/init.js',
'knobs-and-levers.js',
......
......@@ -7,7 +7,7 @@ var knobsAndLevers = {
this.player.init(this);
this.laser.init(this);
this.mushrooms.init(this);
this.spider.init(this);
this.spiders.init(this);
this.text.init(this);
this.worms.init(this);
console.log('knobsAndLevers initialized');
......@@ -112,7 +112,7 @@ var knobsAndLevers = {
},
},
game : {
playerCollisionsEnabled : false,
playerCollisionsEnabled : true,
interval : {
min : 0,
max : 0,
......@@ -262,7 +262,7 @@ var knobsAndLevers = {
knobsAndLevers.resetParameter(this.speed);
},
},
spider : {
spiders : {
maxNumber : 0,
pointValue : 400,
interval : {
......
......@@ -11,7 +11,7 @@ describe('SPIDERS SPEC: ', () => {
knobsAndLevers.init();
});
it('init sets interval from knobsAndLevers', () => {
let expected = knobsAndLevers.spider.initialInterval;
let expected = knobsAndLevers.spiders.initialInterval;
testObj.init();
......@@ -66,7 +66,7 @@ describe('SPIDERS SPEC: ', () => {
it('maxedOut returns true if spiders array >= max', () => {
testObj.spiders = [];
while (testObj.spiders.length < knobsAndLevers.spider.maxNumber) {
while (testObj.spiders.length < knobsAndLevers.spiders.maxNumber) {
testObj.spiders.push({});
};
......@@ -135,7 +135,7 @@ describe('SPIDERS SPEC: ', () => {
});
it('update delegates to spider management functions when spiders array not empty', () => {
testObj.spiders = [new Component(knobsAndLevers.spider.args)];
testObj.spiders = [new Component(knobsAndLevers.spiders.args)];
spyOn(testObj, 'removeMushrooms');
spyOn(testObj, 'updateSpeed');
spyOn(testObj, 'updatePos');
......
......@@ -17,7 +17,7 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
spyOn(testObj.player, 'init');
spyOn(testObj.laser, 'init');
spyOn(testObj.mushrooms, 'init');
spyOn(testObj.spider, 'init');
spyOn(testObj.spiders, 'init');
spyOn(testObj.text, 'init');
spyOn(testObj.worms, 'init');
......@@ -29,7 +29,7 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
expect(testObj.player.init).toHaveBeenCalled();
expect(testObj.laser.init).toHaveBeenCalled();
expect(testObj.mushrooms.init).toHaveBeenCalled();
expect(testObj.spider.init).toHaveBeenCalled();
expect(testObj.spiders.init).toHaveBeenCalled();
expect(testObj.text.init).toHaveBeenCalled();
expect(testObj.worms.init).toHaveBeenCalled();
});
......@@ -75,13 +75,13 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
expect(testObj.mushrooms.scaleFactor).toBeTruthy();
expect(testObj.mushrooms.side).toBeTruthy();
});
it('spider.init initializes spider parameters', () => {
testObj.spider.init(knobsAndLevers);
it('spiders.init initializes spider parameters', () => {
testObj.spiders.init(knobsAndLevers);
expect(testObj.spider.initialInterval).toBeTruthy();
expect(testObj.spider.args.width).toBeTruthy();
expect(testObj.spider.args.height).toBeTruthy();
expect(testObj.spider.args.x).toBeTruthy();
expect(testObj.spiders.initialInterval).toBeTruthy();
expect(testObj.spiders.args.width).toBeTruthy();
expect(testObj.spiders.args.height).toBeTruthy();
expect(testObj.spiders.args.x).toBeTruthy();
});
it('text.init initializes text parameters', () => {
testObj.text.init(knobsAndLevers);
......
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