diff --git a/public/bank.js b/public/bank.js new file mode 100644 index 0000000..91f8ffb --- /dev/null +++ b/public/bank.js @@ -0,0 +1,15 @@ +class Bank { + constructor() { + + } + + draw(x, y, w, h) { + tint(Colors.Purple); + let purple = color(Colors.Purple); + noFill(); + stroke(purple); + strokeWeight(2); + rect(x, y, w, h); + image(Images.bank, x, y, w, h); + } +} diff --git a/public/colors.js b/public/colors.js new file mode 100644 index 0000000..e69de29 diff --git a/public/frame.js b/public/frame.js index bfb4c1c..e69de29 100644 --- a/public/frame.js +++ b/public/frame.js @@ -1,19 +0,0 @@ -// Frame represents an embroidery frame -class Frame { - constructor(options) { - this.x = options.x; - this.y = options.y; - this.width = options.width; - this.height = options.height; - } - - draw() { - stroke(Colors.DarkTan); - strokeWeight(4); - fill(Colors.Tan); - rectMode(CORNERS); - rect(this.x, this.y, this.width, this.height); - } - - -} diff --git a/public/game.js b/public/game.js new file mode 100644 index 0000000..719282b --- /dev/null +++ b/public/game.js @@ -0,0 +1,116 @@ +class Game { + constructor (w, h) { + this.w = w; + this.h = h; + this.players = {}; + this.numPlayers = 0; + this.id = 0; + this.colliders = new Group(); + this.spawner = new ZombieSpawner({ + game: this, + minX: 0, + maxX: w, + minY: 0, + maxY: 100, + }); + this.zombies = []; + this.store = new Store(); + this.bank = new Bank(); + } + + add (id, x, y, w, h) { + this.players[id] = createSprite(x, y, w, h); + this.players[id].id = "p"+this.id; + this.players[id].setCollider("rectangle", 0, 0, w, h); + this.players[id].color = color(255, 255, 255); + this.players[id].shapeColor = color(255, 255, 255); + this.players[id].scale = 1; + this.players[id].mass = 1; + this.colliders.add(this.players[id]); + print(this.players[id].id + " added."); + this.id++; + this.numPlayers++; + } + + update() { + this.checkBounds(); + this.zombies.forEach(z => z.update()); + this.zombies = this.zombies.filter(z => !z.isDead()); + } + + draw() { + this.update(); + this.bank.draw(width*0.25 - 64, height - 128 - 32, 128, 128); + this.store.draw(width*0.75 - 64, height - 128 - 32, 128, 128); + this.zombies.forEach(z => z.draw()); + drawSprites(); + } + + setColor (id, r, g, b) { + this.players[id].color = color(r, g, b); + this.players[id].shapeColor = color(r, g, b); + + print(this.players[id].id + " color added."); + } + + remove (id) { + this.colliders.remove(this.players[id]); + this.players[id].remove(); + delete this.players[id]; + this.numPlayers--; + } + + checkId (id) { + if (id in this.players) { return true; } + else { return false; } + } + + printPlayerIds (x, y) { + push(); + noStroke(); + fill(Colors.Eggplant); + textSize(16); + text("# players: " + this.numPlayers, x, y); + + y = y + 16; + fill(Colors.Eggplant); + for (let id in this.players) { + text(this.players[id].id, x, y); + y += 16; + } + + pop(); + } + + setVelocity(id, velx, vely) { + this.players[id].velocity.x = velx; + this.players[id].velocity.y = vely; + } + + checkBounds() { + for (let id in this.players) { + + if (this.players[id].position.x < 0) { + this.players[id].position.x = this.w - 1; + } + + if (this.players[id].position.x > this.w) { + this.players[id].position.x = 1; + } + + if (this.players[id].position.y < 0) { + this.players[id].position.y = this.h - 1; + } + + if (this.players[id].position.y > this.h) { + this.players[id].position.y = 1; + } + } + } + + addZombie(zombie) { + console.log(["adding zombie", zombie]); + this.zombies.push(zombie); + } +} + diff --git a/public/host.html b/public/host.html index 32d972e..2f01b75 100644 --- a/public/host.html +++ b/public/host.html @@ -15,7 +15,11 @@ - + + + + + diff --git a/public/host.js b/public/host.js index 0490651..6eabc0a 100644 --- a/public/host.js +++ b/public/host.js @@ -30,6 +30,7 @@ let game; function preload() { setupHost(); + Images.loadAll(); } function setup () { @@ -47,7 +48,7 @@ function windowResized() { } function draw () { - background(255); + background(Colors.Sky); if(isHostConnected(display=true)) { // Host/Game draw here. ---> @@ -142,107 +143,3 @@ function processButton (data) { data.button); } } - -//////////// -// Game -// This simple placeholder game makes use of p5.play -class Game { - constructor (w, h) { - this.w = w; - this.h = h; - this.players = {}; - this.numPlayers = 0; - this.id = 0; - this.colliders = new Group(); - this.frames = [ - new Frame({ - x: 100, - y: 100, - width: 200, - height: 200 - }) - ]; - } - - add (id, x, y, w, h) { - this.players[id] = createSprite(x, y, w, h); - this.players[id].id = "p"+this.id; - this.players[id].setCollider("rectangle", 0, 0, w, h); - this.players[id].color = color(255, 255, 255); - this.players[id].shapeColor = color(255, 255, 255); - this.players[id].scale = 1; - this.players[id].mass = 1; - this.colliders.add(this.players[id]); - print(this.players[id].id + " added."); - this.id++; - this.numPlayers++; - } - - draw() { - this.frames.forEach(f => f.draw()); - this.checkBounds(); - drawSprites(); - } - - setColor (id, r, g, b) { - this.players[id].color = color(r, g, b); - this.players[id].shapeColor = color(r, g, b); - - print(this.players[id].id + " color added."); - } - - remove (id) { - this.colliders.remove(this.players[id]); - this.players[id].remove(); - delete this.players[id]; - this.numPlayers--; - } - - checkId (id) { - if (id in this.players) { return true; } - else { return false; } - } - - printPlayerIds (x, y) { - push(); - noStroke(); - fill(Colors.Blackish); - textSize(16); - text("# players: " + this.numPlayers, x, y); - - y = y + 16; - fill(Colors.Blackish); - for (let id in this.players) { - text(this.players[id].id, x, y); - y += 16; - } - - pop(); - } - - setVelocity(id, velx, vely) { - this.players[id].velocity.x = velx; - this.players[id].velocity.y = vely; - } - - checkBounds() { - for (let id in this.players) { - - if (this.players[id].position.x < 0) { - this.players[id].position.x = this.w - 1; - } - - if (this.players[id].position.x > this.w) { - this.players[id].position.x = 1; - } - - if (this.players[id].position.y < 0) { - this.players[id].position.y = this.h - 1; - } - - if (this.players[id].position.y > this.h) { - this.players[id].position.y = 1; - } - } - } -} diff --git a/public/images.js b/public/images.js new file mode 100644 index 0000000..329f9a8 --- /dev/null +++ b/public/images.js @@ -0,0 +1,72 @@ +const Images = { + loadAll() { + this.zombies = [ + loadImage("images/noun_Zombie_1304637.png"), + loadImage("images/noun_Zombie_1304638.png"), + loadImage("images/noun_Zombie_1304639.png"), + loadImage("images/noun_Zombie_1304640.png"), + loadImage("images/noun_Zombie_1304641.png"), + loadImage("images/noun_Zombie_1304645.png"), + loadImage("images/noun_Zombie_1322609.png"), + loadImage("images/noun_Zombie_1322610.png"), + loadImage("images/noun_Zombie_1322611.png"), + loadImage("images/noun_Zombie_1322612.png"), + loadImage("images/noun_Zombie_1322613.png"), + loadImage("images/noun_Zombie_1322614.png"), + loadImage("images/noun_Zombie_1322615.png"), + loadImage("images/noun_Zombie_1322616.png"), + loadImage("images/noun_Zombie_1322617.png"), + loadImage("images/noun_Zombie_1322618.png"), + loadImage("images/noun_Zombie_1322619.png"), + loadImage("images/noun_Zombie_1322620.png"), + loadImage("images/noun_Zombie_1322621.png"), + loadImage("images/noun_Zombie_1322622.png"), + loadImage("images/noun_Zombie_1322623.png"), + loadImage("images/noun_Zombie_1322624.png"), + loadImage("images/noun_Zombie_1322625.png"), + loadImage("images/noun_Zombie_1322626.png"), + loadImage("images/noun_Zombie_1322627.png"), + loadImage("images/noun_Zombie_1322628.png"), + loadImage("images/noun_Zombie_1322629.png"), + loadImage("images/noun_Zombie_1322630.png"), + loadImage("images/noun_Zombie_1322631.png"), + loadImage("images/noun_Zombie_1322632.png"), + loadImage("images/noun_Zombie_1322633.png"), + loadImage("images/noun_Zombie_1322634.png"), + loadImage("images/noun_Zombie_1322635.png"), + loadImage("images/noun_Zombie_1322636.png"), + loadImage("images/noun_Zombie_1322637.png"), + loadImage("images/noun_Zombie_1322638.png"), + loadImage("images/noun_Zombie_1322639.png"), + loadImage("images/noun_Zombie_1322640.png"), + loadImage("images/noun_Zombie_1322641.png"), + loadImage("images/noun_Zombie_1322642.png"), + loadImage("images/noun_Zombie_1322643.png"), + loadImage("images/noun_Zombie_1322644.png") + ]; + this.playerAvatars = [ + loadImage("images/noun_Baby_851140.png"), + loadImage("images/noun_Bear_812815.png"), + loadImage("images/noun_cool_925419.png"), + loadImage("images/noun_cool_925435.png"), + loadImage("images/noun_evil_925412.png"), + loadImage("images/noun_evil_925432.png"), + loadImage("images/noun_girl_922146.png"), + loadImage("images/noun_Happy_925423.png"), + loadImage("images/noun_joy_925443.png"), + loadImage("images/noun_joyful_925420.png"), + loadImage("images/noun_joyful_925439.png"), + loadImage("images/noun_Lady_922143.png"), + loadImage("images/noun_Man_922145.png"), + loadImage("images/noun_Man_922164.png"), + loadImage("images/noun_monkey_face.png"), + loadImage("images/noun_Robot_835621.png"), + loadImage("images/noun_teddy_bear.png") + ]; + this.bank = loadImage("images/noun_Bank_873947.png"); + this.burger = loadImage("images/noun_cheeseburger_940494.png"); + this.crown = loadImage("images/noun_Crown_801129.png"); + this.cash = loadImage("images/noun_money_bag.png"); + this.restaurant = loadImage("images/noun_restaurant.png"); + } +} diff --git a/public/images/noun_Baby_851140.png b/public/images/noun_Baby_851140.png new file mode 100644 index 0000000..71b3c3b Binary files /dev/null and b/public/images/noun_Baby_851140.png differ diff --git a/public/images/noun_Bank_873947.png b/public/images/noun_Bank_873947.png new file mode 100644 index 0000000..e9b0b20 Binary files /dev/null and b/public/images/noun_Bank_873947.png differ diff --git a/public/images/noun_Bear_812815.png b/public/images/noun_Bear_812815.png new file mode 100644 index 0000000..981946b Binary files /dev/null and b/public/images/noun_Bear_812815.png differ diff --git a/public/images/noun_Crown_801129.png b/public/images/noun_Crown_801129.png new file mode 100644 index 0000000..fc067f0 Binary files /dev/null and b/public/images/noun_Crown_801129.png differ diff --git a/public/images/noun_Happy_925423.png b/public/images/noun_Happy_925423.png new file mode 100644 index 0000000..e0ee420 Binary files /dev/null and b/public/images/noun_Happy_925423.png differ diff --git a/public/images/noun_Lady_922143.png b/public/images/noun_Lady_922143.png new file mode 100644 index 0000000..db9522a Binary files /dev/null and b/public/images/noun_Lady_922143.png differ diff --git a/public/images/noun_Man_922145.png b/public/images/noun_Man_922145.png new file mode 100644 index 0000000..d7dc34d Binary files /dev/null and b/public/images/noun_Man_922145.png differ diff --git a/public/images/noun_Man_922164.png b/public/images/noun_Man_922164.png new file mode 100644 index 0000000..6a29fff Binary files /dev/null and b/public/images/noun_Man_922164.png differ diff --git a/public/images/noun_Papaya_891140.png b/public/images/noun_Papaya_891140.png new file mode 100644 index 0000000..fc20c87 Binary files /dev/null and b/public/images/noun_Papaya_891140.png differ diff --git a/public/images/noun_Pizza_940467.png b/public/images/noun_Pizza_940467.png new file mode 100644 index 0000000..d8de145 Binary files /dev/null and b/public/images/noun_Pizza_940467.png differ diff --git a/public/images/noun_Robot_835621.png b/public/images/noun_Robot_835621.png new file mode 100644 index 0000000..1545873 Binary files /dev/null and b/public/images/noun_Robot_835621.png differ diff --git a/public/images/noun_Zombie_1304637.png b/public/images/noun_Zombie_1304637.png new file mode 100644 index 0000000..c1ccf0a Binary files /dev/null and b/public/images/noun_Zombie_1304637.png differ diff --git a/public/images/noun_Zombie_1304638.png b/public/images/noun_Zombie_1304638.png new file mode 100644 index 0000000..23dfe7d Binary files /dev/null and b/public/images/noun_Zombie_1304638.png differ diff --git a/public/images/noun_Zombie_1304639.png b/public/images/noun_Zombie_1304639.png new file mode 100644 index 0000000..ee80763 Binary files /dev/null and b/public/images/noun_Zombie_1304639.png differ diff --git a/public/images/noun_Zombie_1304640.png b/public/images/noun_Zombie_1304640.png new file mode 100644 index 0000000..661dd89 Binary files /dev/null and b/public/images/noun_Zombie_1304640.png differ diff --git a/public/images/noun_Zombie_1304641.png b/public/images/noun_Zombie_1304641.png new file mode 100644 index 0000000..4408ba3 Binary files /dev/null and b/public/images/noun_Zombie_1304641.png differ diff --git a/public/images/noun_Zombie_1304645.png b/public/images/noun_Zombie_1304645.png new file mode 100644 index 0000000..5e8381a Binary files /dev/null and b/public/images/noun_Zombie_1304645.png differ diff --git a/public/images/noun_Zombie_1322609.png b/public/images/noun_Zombie_1322609.png new file mode 100644 index 0000000..eefce71 Binary files /dev/null and b/public/images/noun_Zombie_1322609.png differ diff --git a/public/images/noun_Zombie_1322610.png b/public/images/noun_Zombie_1322610.png new file mode 100644 index 0000000..d8213e5 Binary files /dev/null and b/public/images/noun_Zombie_1322610.png differ diff --git a/public/images/noun_Zombie_1322611.png b/public/images/noun_Zombie_1322611.png new file mode 100644 index 0000000..d742c51 Binary files /dev/null and b/public/images/noun_Zombie_1322611.png differ diff --git a/public/images/noun_Zombie_1322612.png b/public/images/noun_Zombie_1322612.png new file mode 100644 index 0000000..af48e3a Binary files /dev/null and b/public/images/noun_Zombie_1322612.png differ diff --git a/public/images/noun_Zombie_1322613.png b/public/images/noun_Zombie_1322613.png new file mode 100644 index 0000000..95f1eb1 Binary files /dev/null and b/public/images/noun_Zombie_1322613.png differ diff --git a/public/images/noun_Zombie_1322614.png b/public/images/noun_Zombie_1322614.png new file mode 100644 index 0000000..bbdbc97 Binary files /dev/null and b/public/images/noun_Zombie_1322614.png differ diff --git a/public/images/noun_Zombie_1322615.png b/public/images/noun_Zombie_1322615.png new file mode 100644 index 0000000..eba7a1d Binary files /dev/null and b/public/images/noun_Zombie_1322615.png differ diff --git a/public/images/noun_Zombie_1322616.png b/public/images/noun_Zombie_1322616.png new file mode 100644 index 0000000..b3ac323 Binary files /dev/null and b/public/images/noun_Zombie_1322616.png differ diff --git a/public/images/noun_Zombie_1322617.png b/public/images/noun_Zombie_1322617.png new file mode 100644 index 0000000..7ce504c Binary files /dev/null and b/public/images/noun_Zombie_1322617.png differ diff --git a/public/images/noun_Zombie_1322618.png b/public/images/noun_Zombie_1322618.png new file mode 100644 index 0000000..0d69e21 Binary files /dev/null and b/public/images/noun_Zombie_1322618.png differ diff --git a/public/images/noun_Zombie_1322619.png b/public/images/noun_Zombie_1322619.png new file mode 100644 index 0000000..f0eed79 Binary files /dev/null and b/public/images/noun_Zombie_1322619.png differ diff --git a/public/images/noun_Zombie_1322620.png b/public/images/noun_Zombie_1322620.png new file mode 100644 index 0000000..681e832 Binary files /dev/null and b/public/images/noun_Zombie_1322620.png differ diff --git a/public/images/noun_Zombie_1322621.png b/public/images/noun_Zombie_1322621.png new file mode 100644 index 0000000..8a110e0 Binary files /dev/null and b/public/images/noun_Zombie_1322621.png differ diff --git a/public/images/noun_Zombie_1322622.png b/public/images/noun_Zombie_1322622.png new file mode 100644 index 0000000..395e1ae Binary files /dev/null and b/public/images/noun_Zombie_1322622.png differ diff --git a/public/images/noun_Zombie_1322623.png b/public/images/noun_Zombie_1322623.png new file mode 100644 index 0000000..02ee1bb Binary files /dev/null and b/public/images/noun_Zombie_1322623.png differ diff --git a/public/images/noun_Zombie_1322624.png b/public/images/noun_Zombie_1322624.png new file mode 100644 index 0000000..3ee0086 Binary files /dev/null and b/public/images/noun_Zombie_1322624.png differ diff --git a/public/images/noun_Zombie_1322625.png b/public/images/noun_Zombie_1322625.png new file mode 100644 index 0000000..ffb5ba4 Binary files /dev/null and b/public/images/noun_Zombie_1322625.png differ diff --git a/public/images/noun_Zombie_1322626.png b/public/images/noun_Zombie_1322626.png new file mode 100644 index 0000000..6fca888 Binary files /dev/null and b/public/images/noun_Zombie_1322626.png differ diff --git a/public/images/noun_Zombie_1322627.png b/public/images/noun_Zombie_1322627.png new file mode 100644 index 0000000..e70a14c Binary files /dev/null and b/public/images/noun_Zombie_1322627.png differ diff --git a/public/images/noun_Zombie_1322628.png b/public/images/noun_Zombie_1322628.png new file mode 100644 index 0000000..62c462e Binary files /dev/null and b/public/images/noun_Zombie_1322628.png differ diff --git a/public/images/noun_Zombie_1322629.png b/public/images/noun_Zombie_1322629.png new file mode 100644 index 0000000..e2add64 Binary files /dev/null and b/public/images/noun_Zombie_1322629.png differ diff --git a/public/images/noun_Zombie_1322630.png b/public/images/noun_Zombie_1322630.png new file mode 100644 index 0000000..da4ab51 Binary files /dev/null and b/public/images/noun_Zombie_1322630.png differ diff --git a/public/images/noun_Zombie_1322631.png b/public/images/noun_Zombie_1322631.png new file mode 100644 index 0000000..c6f133c Binary files /dev/null and b/public/images/noun_Zombie_1322631.png differ diff --git a/public/images/noun_Zombie_1322632.png b/public/images/noun_Zombie_1322632.png new file mode 100644 index 0000000..96f156e Binary files /dev/null and b/public/images/noun_Zombie_1322632.png differ diff --git a/public/images/noun_Zombie_1322633.png b/public/images/noun_Zombie_1322633.png new file mode 100644 index 0000000..48819d4 Binary files /dev/null and b/public/images/noun_Zombie_1322633.png differ diff --git a/public/images/noun_Zombie_1322634.png b/public/images/noun_Zombie_1322634.png new file mode 100644 index 0000000..392bcb1 Binary files /dev/null and b/public/images/noun_Zombie_1322634.png differ diff --git a/public/images/noun_Zombie_1322635.png b/public/images/noun_Zombie_1322635.png new file mode 100644 index 0000000..c5c9565 Binary files /dev/null and b/public/images/noun_Zombie_1322635.png differ diff --git a/public/images/noun_Zombie_1322636.png b/public/images/noun_Zombie_1322636.png new file mode 100644 index 0000000..443e294 Binary files /dev/null and b/public/images/noun_Zombie_1322636.png differ diff --git a/public/images/noun_Zombie_1322637.png b/public/images/noun_Zombie_1322637.png new file mode 100644 index 0000000..cedca6a Binary files /dev/null and b/public/images/noun_Zombie_1322637.png differ diff --git a/public/images/noun_Zombie_1322638.png b/public/images/noun_Zombie_1322638.png new file mode 100644 index 0000000..08e34c0 Binary files /dev/null and b/public/images/noun_Zombie_1322638.png differ diff --git a/public/images/noun_Zombie_1322639.png b/public/images/noun_Zombie_1322639.png new file mode 100644 index 0000000..c5eb024 Binary files /dev/null and b/public/images/noun_Zombie_1322639.png differ diff --git a/public/images/noun_Zombie_1322640.png b/public/images/noun_Zombie_1322640.png new file mode 100644 index 0000000..9faadaa Binary files /dev/null and b/public/images/noun_Zombie_1322640.png differ diff --git a/public/images/noun_Zombie_1322641.png b/public/images/noun_Zombie_1322641.png new file mode 100644 index 0000000..e76bbeb Binary files /dev/null and b/public/images/noun_Zombie_1322641.png differ diff --git a/public/images/noun_Zombie_1322642.png b/public/images/noun_Zombie_1322642.png new file mode 100644 index 0000000..7e74191 Binary files /dev/null and b/public/images/noun_Zombie_1322642.png differ diff --git a/public/images/noun_Zombie_1322643.png b/public/images/noun_Zombie_1322643.png new file mode 100644 index 0000000..2468546 Binary files /dev/null and b/public/images/noun_Zombie_1322643.png differ diff --git a/public/images/noun_Zombie_1322644.png b/public/images/noun_Zombie_1322644.png new file mode 100644 index 0000000..7d72fc9 Binary files /dev/null and b/public/images/noun_Zombie_1322644.png differ diff --git a/public/images/noun_cash_812725.png b/public/images/noun_cash_812725.png new file mode 100644 index 0000000..34f47ed Binary files /dev/null and b/public/images/noun_cash_812725.png differ diff --git a/public/images/noun_cheeseburger_940494.png b/public/images/noun_cheeseburger_940494.png new file mode 100644 index 0000000..1b16ec6 Binary files /dev/null and b/public/images/noun_cheeseburger_940494.png differ diff --git a/public/images/noun_cool_925419.png b/public/images/noun_cool_925419.png new file mode 100644 index 0000000..26ceb03 Binary files /dev/null and b/public/images/noun_cool_925419.png differ diff --git a/public/images/noun_cool_925435.png b/public/images/noun_cool_925435.png new file mode 100644 index 0000000..107538a Binary files /dev/null and b/public/images/noun_cool_925435.png differ diff --git a/public/images/noun_evil_925412.png b/public/images/noun_evil_925412.png new file mode 100644 index 0000000..59c05a8 Binary files /dev/null and b/public/images/noun_evil_925412.png differ diff --git a/public/images/noun_evil_925432.png b/public/images/noun_evil_925432.png new file mode 100644 index 0000000..c05754a Binary files /dev/null and b/public/images/noun_evil_925432.png differ diff --git a/public/images/noun_girl_922146.png b/public/images/noun_girl_922146.png new file mode 100644 index 0000000..04832fd Binary files /dev/null and b/public/images/noun_girl_922146.png differ diff --git a/public/images/noun_joy_925443.png b/public/images/noun_joy_925443.png new file mode 100644 index 0000000..cd87d80 Binary files /dev/null and b/public/images/noun_joy_925443.png differ diff --git a/public/images/noun_joyful_925420.png b/public/images/noun_joyful_925420.png new file mode 100644 index 0000000..5358982 Binary files /dev/null and b/public/images/noun_joyful_925420.png differ diff --git a/public/images/noun_joyful_925439.png b/public/images/noun_joyful_925439.png new file mode 100644 index 0000000..d74aba1 Binary files /dev/null and b/public/images/noun_joyful_925439.png differ diff --git a/public/images/noun_money_bag.png b/public/images/noun_money_bag.png new file mode 100644 index 0000000..2e720a6 Binary files /dev/null and b/public/images/noun_money_bag.png differ diff --git a/public/images/noun_monkey_face.png b/public/images/noun_monkey_face.png new file mode 100644 index 0000000..6ca1e47 Binary files /dev/null and b/public/images/noun_monkey_face.png differ diff --git a/public/images/noun_restaurant.png b/public/images/noun_restaurant.png new file mode 100644 index 0000000..1af22cd Binary files /dev/null and b/public/images/noun_restaurant.png differ diff --git a/public/images/noun_teddy_bear.png b/public/images/noun_teddy_bear.png new file mode 100644 index 0000000..c14a3e4 Binary files /dev/null and b/public/images/noun_teddy_bear.png differ diff --git a/public/images/noun_tropical_fruit.png b/public/images/noun_tropical_fruit.png new file mode 100644 index 0000000..19a0924 Binary files /dev/null and b/public/images/noun_tropical_fruit.png differ diff --git a/public/lib/p5.multiplayer.js b/public/lib/p5.multiplayer.js index 140930c..fbde79a 100644 --- a/public/lib/p5.multiplayer.js +++ b/public/lib/p5.multiplayer.js @@ -1,9 +1,9 @@ const Colors = { - Tan: "#D8BDB3", - DarkTan: "#A58072", - Blackish: "#262523", - Blood: "#8C021C", - Rust: "#590910", + Eggplant: "#26011C", + Purple: "#59024B", + Sky: "#05F2DB", + DarkGreen: "#038C33", + LightGreen: "#84D930", }; //////////// @@ -91,10 +91,10 @@ function onHostConnect (data) { // Displays server address in lower left of screen function displayAddress() { push(); - fill(Colors.Blackish); + fill(Colors.Eggplant); noStroke(); textSize(50); - text(serverIp+"/?="+roomId, 10, height-50); + text(serverIp+"/?="+roomId, 10, 50); pop(); } diff --git a/public/store.js b/public/store.js new file mode 100644 index 0000000..822d0db --- /dev/null +++ b/public/store.js @@ -0,0 +1,15 @@ +class Store { + constructor() { + + } + + draw(x, y, w, h) { + tint(Colors.Purple); + let purple = color(Colors.Purple); + noFill(); + stroke(purple); + strokeWeight(2); + rect(x, y, w, h); + image(Images.restaurant, x, y, w, h); + } +} diff --git a/public/zombie.js b/public/zombie.js new file mode 100644 index 0000000..ece7e16 --- /dev/null +++ b/public/zombie.js @@ -0,0 +1,51 @@ +class Zombie { + constructor(options) { + options = options || {}; + this.x = options.x; + this.y = options.y; + this.image = random(Images.zombies); + this.alive = true; + } + + update() { + this.y += 1; + } + + draw() { + tint(Colors.DarkGreen); + image(this.image, this.x, this.y, 64, 64); + } + + isDead() { + return !this.alive || this.y > height; + } +} + +class ZombieSpawner { + constructor(options) { + options = options || {}; + this.game = options.game; + this.minT = options.minT || 500; + this.maxT = options.maxT || 3000; + this.minX = options.minX || 0; + this.maxX = options.maxX || 500; + this.minY = options.minY || 100; + this.maxY = options.maxY || 100; + this.planNextSpawn(); + } + + planNextSpawn() { + let t = random(this.minT, this.maxT); + console.log(`will add next zombie in ${t}`); + this.nextSpawn = setTimeout(() => this.spawnZombie(), t); + } + + spawnZombie() { + let zombie = new Zombie({ + x: random(this.minX, this.maxX), + y: random(this.minY, this.maxY), + }); + this.game.addZombie(zombie); + this.planNextSpawn(); + } +}