Commit d78b31e1 authored by Matthew Odle's avatar Matthew Odle

rename intervalCreatures to gameObjects

parent 2738c2b0
......@@ -16,8 +16,8 @@ var collisions = {
let targets = [];
targets.push(...mushrooms.mushrooms);
targets.push(...centipedes.centipedes);
targets.push(...intervalCreatures.worms);
targets.push(...intervalCreatures.flies);
targets.push(...gameObjects.worms);
targets.push(...gameObjects.flies);
targets.push(...spiders.spiders);
return targets;
},
......@@ -73,7 +73,7 @@ var collisions = {
targets = [];
targets.push(...centipedes.centipedes);
targets.push(...spiders.spiders);
targets.push(...intervalCreatures.flies);
targets.push(...gameObjects.flies);
return targets;
},
checkPlayerVsEnemies : function(player, targets) {
......@@ -101,8 +101,8 @@ var collisions = {
removeDestroyedTargets : function(targets) {
mushrooms.mushrooms = mushrooms.mushrooms.filter(mushroom => mushroom.hitPoints > 0);
centipedes.centipedes = centipedes.centipedes.filter(centipede => centipede.hitPoints > 0);
intervalCreatures.worms = intervalCreatures.worms.filter(worm => worm.hitPoints > 0);
intervalCreatures.flies = intervalCreatures.flies.filter(fly => fly.hitPoints > 0);
gameObjects.worms = gameObjects.worms.filter(worm => worm.hitPoints > 0);
gameObjects.flies = gameObjects.flies.filter(fly => fly.hitPoints > 0);
spiders.spiders = spiders.spiders.filter(spider => spider.hitPoints > 0);
},
}
/*jslint white: true */
var intervalCreatures = {
var gameObjects = {
worms : [],
flies : [],
init : function() {
......@@ -7,7 +7,7 @@ var intervalCreatures = {
flies : knobsAndLevers.flies.initialInterval,
worms : knobsAndLevers.worms.initialInterval,
};
console.log('intervalCreatures initialized');
console.log('gameObjects initialized');
},
manage : function() {
Object.keys(this.intervals).forEach(type => {
......
......@@ -7,7 +7,7 @@ var init = {
dom.init();
game.init();
initials.init();
intervalCreatures.init();
gameObjects.init();
leaderboard.init();
main.init();
mainMenu.init();
......@@ -27,7 +27,7 @@ var init = {
metrics.init();
spiders.init();
texts.init();
intervalCreatures.init();
gameObjects.init();
game.paused = true;
game.running = false;
console.log("game reset");
......
......@@ -37,7 +37,7 @@ var libs = [
var scripts = [
'collisions.js',
'components/centipedes.js',
'components/interval-creatures.js',
'components/game-objects.js',
'components/lasers.js',
'components/metrics.js',
'components/mushrooms.js',
......
......@@ -11,7 +11,7 @@ var main = {
metrics.manage();
mushrooms.manage();
centipedes.manage();
intervalCreatures.manage();
gameObjects.manage();
spiders.manage();
lasers.manage();
players.manage();
......
......@@ -53,7 +53,7 @@ var sounds = {
},
manageFlySounds : function() {
let sound = this.tracks['fly'];
if (intervalCreatures.flies != false) {
if (gameObjects.flies != false) {
if (!sound.played) {
this.playSound(sound);
};
......@@ -63,7 +63,7 @@ var sounds = {
};
},
manageWormSounds : function() {
if (intervalCreatures.worms != false) {
if (gameObjects.worms != false) {
this.playSound(this.getSound('worm'));
} else {
this.stopSound('worm');
......
......@@ -34,8 +34,8 @@ describe('COLLISIONS SPEC: ', () => {
it('getLaserTargets combines multiple target Arrays', () => {
mushrooms.mushrooms = [];
centipedes.centipedes = [];
intervalCreatures.worms = [];
intervalCreatures.flies = ['anObj'];
gameObjects.worms = [];
gameObjects.flies = ['anObj'];
spiders.spiders = ['anObj'];
targets = testObj.getLaserTargets();
......@@ -182,7 +182,7 @@ describe('COLLISIONS SPEC: ', () => {
it('getPlayerEnemies combines multiple enemy Arrays', () => {
centipedes.centipedes = [];
intervalCreatures.flies = ['anObj'];
gameObjects.flies = ['anObj'];
spiders.spiders = ['anObj'];
targets = testObj.getPlayerEnemies();
......@@ -288,16 +288,16 @@ describe('COLLISIONS SPEC: ', () => {
it('removeDestroyedTargets removes destroyed targets', () => {
mushrooms.mushrooms = [{hitPoints : 0}, {hitPoints : 1}];
centipedes.centipedes = [{hitPoints : 0}, {hitPoints : 1}];
intervalCreatures.worms = [{hitPoints : 0}, {hitPoints : 1}];
intervalCreatures.flies = [{hitPoints : 0}, {hitPoints : 1}];
gameObjects.worms = [{hitPoints : 0}, {hitPoints : 1}];
gameObjects.flies = [{hitPoints : 0}, {hitPoints : 1}];
spiders.spiders = [{hitPoints : 0}, {hitPoints : 1}];
testObj.removeDestroyedTargets();
expect(mushrooms.mushrooms.length).toEqual(1);
expect(centipedes.centipedes.length).toEqual(1);
expect(intervalCreatures.worms.length).toEqual(1);
expect(intervalCreatures.flies.length).toEqual(1);
expect(gameObjects.worms.length).toEqual(1);
expect(gameObjects.flies.length).toEqual(1);
expect(spiders.spiders.length).toEqual(1);
});
});
......@@ -9,7 +9,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
beforeEach(function () {
knobsAndLevers.init();
game.init();
testObj = Object.assign({}, intervalCreatures);
testObj = Object.assign({}, gameObjects);
testObj.init();
testObj.worms = [];
testObj.flies = [];
......@@ -21,7 +21,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
spyOn(testObj, 'dropMushrooms');
testObj.intervals['worms'] = 10;
};
it('manage calls intervalCreatures.clearOutsideCanvas', () => {
it('manage calls gameObjects.clearOutsideCanvas', () => {
mockTestObj();
testObj.worms.push('a worm');
......@@ -29,7 +29,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
expect(testObj.clearOutsideCanvas).toHaveBeenCalled();
});
it('manage calls intervalCreatures.update', () => {
it('manage calls gameObjects.update', () => {
mockTestObj();
testObj.worms.push('a worm');
......@@ -58,7 +58,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
expect(supporting.getRandom).not.toHaveBeenCalled();
});
it('manage calls intervalCreatures.spawnCreatureAtIntervals', () => {
it('manage calls gameObjects.spawnCreatureAtIntervals', () => {
mockTestObj();
testObj.manage();
......
......@@ -153,14 +153,14 @@ describe('GAME SPEC: ', () => {
});
it('resetMoreThings resets more things', () => {
spyOn(testObj, 'resetSomeThings');
spyOn(intervalCreatures, 'clear');
spyOn(gameObjects, 'clear');
spyOn(spiders, 'clear');
spyOn(player, 'reset');
testObj.resetMoreThings();
expect(testObj.resetSomeThings).toHaveBeenCalled();
expect(intervalCreatures.clear).toHaveBeenCalled();
expect(gameObjects.clear).toHaveBeenCalled();
expect(spiders.clear).toHaveBeenCalled();
expect(player.reset).toHaveBeenCalled();
});
......
......@@ -305,7 +305,7 @@ describe('MAIN SPEC: ', () => {
it('manageGameObjects calls delegate functions', () => {
spyOn(mushrooms, 'manage');
spyOn(centipedes, 'manage');
spyOn(intervalCreatures, 'manage');
spyOn(gameObjects, 'manage');
spyOn(spiders, 'manage');
spyOn(lasers, 'manage');
spyOn(player, 'manage');
......@@ -316,7 +316,7 @@ describe('MAIN SPEC: ', () => {
expect(mushrooms.manage).toHaveBeenCalled();
expect(centipedes.manage).toHaveBeenCalled();
expect(intervalCreatures.manage).toHaveBeenCalled();
expect(gameObjects.manage).toHaveBeenCalled();
expect(spiders.manage).toHaveBeenCalled();
expect(lasers.manage).toHaveBeenCalled();
expect(player.manage).toHaveBeenCalled();
......
......@@ -89,7 +89,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.playSound).not.toHaveBeenCalled();
});
it('manageFlySounds calls fly sound play', () => {
intervalCreatures.flies = [{}];
gameObjects.flies = [{}];
let testSound = {};
testObj.tracks.fly = testSound;
spyOn(testObj, 'playSound');
......@@ -100,7 +100,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.tracks['fly'].played).toBeTruthy();
});
it('manageFlySounds does not call fly sound play if played is true', () => {
intervalCreatures.flies = [{}];
gameObjects.flies = [{}];
spyOn(testObj.tracks['fly'], 'play');
testObj.tracks['fly'].played = true;
......@@ -110,7 +110,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.tracks['fly'].played).toBeTruthy();
});
it('manageFlySounds sets played to false when fly is not present', () => {
intervalCreatures.flies = [];
gameObjects.flies = [];
spyOn(testObj.tracks['fly'], 'play');
testObj.manageFlySounds();
......@@ -119,7 +119,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.tracks['fly'].played).toBeFalsy();
});
it('manageWormSounds calls worm sound play', () => {
intervalCreatures.worms.push({});
gameObjects.worms.push({});
spyOn(testObj, 'playSound');
testObj.manageWormSounds();
......@@ -127,7 +127,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.playSound).toHaveBeenCalled();
});
it('manageWormSounds calls worm sound stop when no worms', () => {
intervalCreatures.worms = [];
gameObjects.worms = [];
spyOn(testObj, 'playSound');
spyOn(testObj, 'stopSound');
......
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