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

correct collision problems with multiple players

parent 92bcdeb6
......@@ -7,7 +7,7 @@ var collisions = {
this.removeUsedLasers(key);
});
Object.keys(players.players).forEach(player =>
this.checkPlayerVsEnemies(player, this.getPlayerEnemies())
this.checkPlayerVsEnemies(players.players[player], this.getPlayerEnemies())
);
this.removeDestroyedTargets();
},
......@@ -67,7 +67,7 @@ var collisions = {
};
targets.forEach(target => {
if (player.crashWith(target)) {
this.killPlayer(player);
this.killPlayer();
return;
};
});
......
......@@ -124,7 +124,10 @@ var customComponents = {
drawComponent : function(ctx, obj) {
let key = this.imageKeys[obj.type](obj);
if (!obj.images) {
throw 'images is ' + obj.images;
throw 'no images; images is ' + obj.images;
};
if (!obj.images[key]) {
throw 'no key match; images is ' + obj.images;
};
ctx.drawImage(obj.images[key].image, obj.x, obj.y, obj.width, obj.height);
},
......
......@@ -47,7 +47,8 @@ var players = {
player.update();
},
reset : function() {
this.players.forEach(player => {
Object.keys(this.players).forEach(key => {
let player = this.players[key];
player.x = knobsAndLevers.player.startX[0];
player.y = knobsAndLevers.player.startY;
});
......
......@@ -41,7 +41,7 @@ var knobsAndLevers = {
},
centipede : {
baseSpeed : 10,
maxNumber : 100,
maxNumber : 10,
pointValue : 20,
args : {
color : "blue",
......@@ -96,7 +96,7 @@ var knobsAndLevers = {
},
},
game : {
playerCollisionsEnabled : false,
playerCollisionsEnabled : true,
sounds : {
value : true,
default : true,
......@@ -114,8 +114,8 @@ var knobsAndLevers = {
maxMushrooms : 50,
tier : {
incrementScore : 10000,
current: 1,
max : 5,
current: 20,
max : 20,
isMaxed : false,
update : function(newTier) {
this.current = newTier;
......@@ -191,7 +191,7 @@ var knobsAndLevers = {
},
player : {
colors : ['red', 'purple'],
defaultLives : 3,
defaultLives : 1,
dimensions : {width : 30, height : 30},
args : {
width : 30,
......
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