zombies drop money now

master
Jordan Orelli 5 years ago
parent 832601e406
commit 42165639f2

@ -14,6 +14,7 @@ class Game {
}); });
this.zombies = []; this.zombies = [];
this.burgers = []; this.burgers = [];
this.moneys = [];
this.store = new Store(); this.store = new Store();
this.bank = new Bank(); this.bank = new Bank();
} }
@ -45,6 +46,9 @@ class Game {
for (let zombie of this.zombies) { for (let zombie of this.zombies) {
if (burger.overlaps(zombie)) { if (burger.overlaps(zombie)) {
burger.kill(); burger.kill();
let money = new Money(zombie.position.x, zombie.position.y);
this.moneys.push(money);
console.log(["adding money", money]);
zombie.kill(); zombie.kill();
break; break;
} }
@ -65,6 +69,7 @@ class Game {
} }
this.zombies.forEach(z => z.draw()); this.zombies.forEach(z => z.draw());
this.burgers.forEach(b => b.draw()); this.burgers.forEach(b => b.draw());
this.moneys.forEach(m => m.draw());
} }
remove (id) { remove (id) {

@ -16,6 +16,7 @@
<script src="lib/p5.multiplayer.js"></script> <script src="lib/p5.multiplayer.js"></script>
<!-- p5 sketch --> <!-- p5 sketch -->
<script src="util.js"></script> <script src="util.js"></script>
<script src="money.js"></script>
<script src="images.js"></script> <script src="images.js"></script>
<script src="burger.js"></script> <script src="burger.js"></script>
<script src="player.js"></script> <script src="player.js"></script>

@ -0,0 +1,32 @@
class Money {
constructor(x, y) {
this.image = Images.cash;
this.position = {x: x, y: y};
this.velocity = {x: 0, y: 0};
this.width = 32;
this.height = 32;
this.alive = true;
}
draw() {
let half = {
height: this.height * 0.5,
width: this.width * 0.5,
};
tint(Colors.DarkGreen);
image(this.image, this.position.x - half.width, this.position.y - half.height, this.width, this.height);
if (debug) {
strokeWeight(4);
stroke('#FF0000');
point(this.position.x, this.position.y);
strokeWeight(1);
noFill();
rect(this.position.x - half.width, this.position.y - half.height, this.width, this.height);
}
}
}
Money.prototype.bounds = bounds;
Money.prototype.outOfBounds = outOfBounds;
Money.prototype.overlaps = overlaps;
Loading…
Cancel
Save