|
|
@ -5,7 +5,6 @@ class Game {
|
|
|
|
this.players = {};
|
|
|
|
this.players = {};
|
|
|
|
this.numPlayers = 0;
|
|
|
|
this.numPlayers = 0;
|
|
|
|
this.id = 0;
|
|
|
|
this.id = 0;
|
|
|
|
this.colliders = new Group();
|
|
|
|
|
|
|
|
this.spawner = new ZombieSpawner({
|
|
|
|
this.spawner = new ZombieSpawner({
|
|
|
|
game: this,
|
|
|
|
game: this,
|
|
|
|
minX: 0,
|
|
|
|
minX: 0,
|
|
|
@ -14,12 +13,14 @@ class Game {
|
|
|
|
maxY: 0,
|
|
|
|
maxY: 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.zombies = [];
|
|
|
|
this.zombies = [];
|
|
|
|
|
|
|
|
this.burgers = [];
|
|
|
|
this.store = new Store();
|
|
|
|
this.store = new Store();
|
|
|
|
this.bank = new Bank();
|
|
|
|
this.bank = new Bank();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add (id, x, y, w, h) {
|
|
|
|
add (id, x, y, w, h) {
|
|
|
|
let player = new Player({
|
|
|
|
let player = new Player({
|
|
|
|
|
|
|
|
game: this,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
x: x,
|
|
|
|
x: x,
|
|
|
|
y: y,
|
|
|
|
y: y,
|
|
|
@ -27,14 +28,12 @@ class Game {
|
|
|
|
height: h,
|
|
|
|
height: h,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.players[id] = player;
|
|
|
|
this.players[id] = player;
|
|
|
|
// this.colliders.add(player.sprite);
|
|
|
|
|
|
|
|
print(player.id + " added.");
|
|
|
|
print(player.id + " added.");
|
|
|
|
this.id++;
|
|
|
|
this.id++;
|
|
|
|
this.numPlayers++;
|
|
|
|
this.numPlayers++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
update() {
|
|
|
|
update() {
|
|
|
|
// this.checkBounds();
|
|
|
|
|
|
|
|
this.zombies.forEach(z => z.update());
|
|
|
|
this.zombies.forEach(z => z.update());
|
|
|
|
for (let id in this.players) {
|
|
|
|
for (let id in this.players) {
|
|
|
|
let player = this.players[id];
|
|
|
|
let player = this.players[id];
|
|
|
@ -52,19 +51,10 @@ class Game {
|
|
|
|
player.draw();
|
|
|
|
player.draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.zombies.forEach(z => z.draw());
|
|
|
|
this.zombies.forEach(z => z.draw());
|
|
|
|
// drawSprites();
|
|
|
|
this.burgers.forEach(b => b.draw());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setColor (id, r, g, b) {
|
|
|
|
|
|
|
|
// this.players[id].sprite.color = color(r, g, b);
|
|
|
|
|
|
|
|
// this.players[id].sprite.shapeColor = color(r, g, b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(this.players[id].id + " color added.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remove (id) {
|
|
|
|
remove (id) {
|
|
|
|
// this.colliders.remove(this.players[id].sprite);
|
|
|
|
|
|
|
|
// this.players[id].sprite.remove();
|
|
|
|
|
|
|
|
delete this.players[id];
|
|
|
|
delete this.players[id];
|
|
|
|
this.numPlayers--;
|
|
|
|
this.numPlayers--;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -91,6 +81,15 @@ class Game {
|
|
|
|
pop();
|
|
|
|
pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonInput(id, val) {
|
|
|
|
|
|
|
|
console.log(["game sees button input", [id, val]]);
|
|
|
|
|
|
|
|
let player = this.players[id];
|
|
|
|
|
|
|
|
if (player) {
|
|
|
|
|
|
|
|
console.log(["button input has player", player]);
|
|
|
|
|
|
|
|
player.buttonInput(val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
joystickInput(id, x, y) {
|
|
|
|
joystickInput(id, x, y) {
|
|
|
|
let player = this.players[id];
|
|
|
|
let player = this.players[id];
|
|
|
|
if (player) {
|
|
|
|
if (player) {
|
|
|
@ -120,8 +119,16 @@ class Game {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addZombie(zombie) {
|
|
|
|
addZombie(zombie) {
|
|
|
|
console.log(["adding zombie", zombie]);
|
|
|
|
|
|
|
|
this.zombies.push(zombie);
|
|
|
|
this.zombies.push(zombie);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addBurger(id) {
|
|
|
|
|
|
|
|
let player = this.players[id];
|
|
|
|
|
|
|
|
if (player) {
|
|
|
|
|
|
|
|
let burger = new Burger(player.sprite.position.x, player.sprite.position.y);
|
|
|
|
|
|
|
|
console.log(["adding burger", burger]);
|
|
|
|
|
|
|
|
this.burgers.push(burger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|