diff --git a/assets/sfx/bang.mp3 b/assets/sfx/bang.mp3 new file mode 100644 index 0000000..d6e8677 Binary files /dev/null and b/assets/sfx/bang.mp3 differ diff --git a/assets/sfx/blast.mp3 b/assets/sfx/blast.mp3 new file mode 100644 index 0000000..2dca2f0 Binary files /dev/null and b/assets/sfx/blast.mp3 differ diff --git a/assets/sfx/bomb2.mp3 b/assets/sfx/bomb2.mp3 new file mode 100644 index 0000000..da35b32 Binary files /dev/null and b/assets/sfx/bomb2.mp3 differ diff --git a/assets/sfx/boom.mp3 b/assets/sfx/boom.mp3 new file mode 100644 index 0000000..9b92b39 Binary files /dev/null and b/assets/sfx/boom.mp3 differ diff --git a/assets/sfx/firebomb.mp3 b/assets/sfx/firebomb.mp3 new file mode 100644 index 0000000..88c9697 Binary files /dev/null and b/assets/sfx/firebomb.mp3 differ diff --git a/assets/sfx/hus.mp3 b/assets/sfx/hus.mp3 new file mode 100644 index 0000000..bfaf996 Binary files /dev/null and b/assets/sfx/hus.mp3 differ diff --git a/assets/sfx/laser.mp3 b/assets/sfx/laser.mp3 index 25ed4b2..367b1fc 100644 Binary files a/assets/sfx/laser.mp3 and b/assets/sfx/laser.mp3 differ diff --git a/assets/sfx/laser2.mp3 b/assets/sfx/laser2.mp3 new file mode 100644 index 0000000..25ed4b2 Binary files /dev/null and b/assets/sfx/laser2.mp3 differ diff --git a/assets/sfx/smallbomb.mp3 b/assets/sfx/smallbomb.mp3 new file mode 100644 index 0000000..134d2bd Binary files /dev/null and b/assets/sfx/smallbomb.mp3 differ diff --git a/index.html b/index.html index a0438d6..e357342 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@ .info { margin: auto; padding-bottom: 100px; - } + } button { padding: 10px; @@ -126,12 +126,16 @@

You Win!

Level:

Score:

+ + + + \ No newline at end of file diff --git a/js/AssetMan.js b/js/AssetMan.js index b8a2089..e7231dc 100644 --- a/js/AssetMan.js +++ b/js/AssetMan.js @@ -6,8 +6,9 @@ class AssetMan { preload() { this.sounds.music = loadSound('./assets/sfx/music.mp3'); - this.sounds.pew = loadSound('./assets/sfx/laser.mp3'); + this.sounds.pew = loadSound('./assets/sfx/laser2.mp3'); this.sounds.gameover = loadSound('./assets/sfx/gameover.mp3'); this.sounds.gamewin = loadSound('./assets/sfx/win.mp3'); + this.sounds.blast = loadSound('./assets/sfx/bomb2.mp3'); } } \ No newline at end of file diff --git a/js/Bullet.js b/js/Bullet.js index 734a594..1d35a46 100644 --- a/js/Bullet.js +++ b/js/Bullet.js @@ -11,12 +11,13 @@ class Bullet { this.pos = createVector(spos.x, spos.y); this.vel = p5.Vector.fromAngle(angle); this.vel.mult(10); + this.angle = angle; } update() { this.pos.add(this.vel); }; - + render() { push(); stroke(255); diff --git a/js/Game.js b/js/Game.js index 2a0e66b..b9ed2cd 100644 --- a/js/Game.js +++ b/js/Game.js @@ -12,6 +12,7 @@ class Game { this.countDown = 1; this.ship = new Player(); this.bullets = []; + this.particles = []; this.rocks = []; this.sounds = assets.sounds; this.level = 1; @@ -46,6 +47,7 @@ class Game { window.clearInterval(timer); }, 2000); + this.sounds.blast.amp(0.03); this.sounds.music.setLoop(true) this.sounds.music.amp(0.2); this.sounds.music.play(); @@ -120,9 +122,7 @@ class Game { handleLevels() { if (this.level === 1) { - let r = new Rock(); - r.radius = 15; - this.rocks.push(r); + this.rocks.push(new Rock(random(width), random(height), 20)); } if (this.level === 2) { this.rockBreakRadius = 25; diff --git a/js/Particle.js b/js/Particle.js new file mode 100644 index 0000000..e196823 --- /dev/null +++ b/js/Particle.js @@ -0,0 +1,20 @@ +class Particle extends Bullet { + constructor(spos, angle) { + super(spos, angle); + + this.vel = p5.Vector.random2D(); + this.life = 1; + } + + render() { + this.vel.y += random(-0.2, 0.2); + push(); + stroke(255, this.life * 255); + strokeWeight(2); + point(this.pos.x, this.pos.y); + pop(); + }; + die() { + this.life -= 0.03; + } +} \ No newline at end of file diff --git a/js/Player.js b/js/Player.js index 0514c86..a09d3ac 100644 --- a/js/Player.js +++ b/js/Player.js @@ -111,7 +111,6 @@ class Player { } render() { - push(); translate(this.pos.x, this.pos.y); // text(this.tailDots.length, 100, 100) diff --git a/js/index.js b/js/index.js index 3006801..9b99158 100644 --- a/js/index.js +++ b/js/index.js @@ -70,6 +70,10 @@ function draw() { game.rocks = game.rocks.concat(newRocks); } // delete the rock and bullet + for (let k = 0; k < 10; k++) { + game.particles.push(new Particle(game.bullets[i].pos)); + game.sounds.blast.play() + } game.rocks.splice(j, 1); game.bullets.splice(i, 1); game.score += 100; @@ -79,4 +83,13 @@ function draw() { } } + for (let i = 0; i < game.particles.length; i++) { + game.particles[i].update(); + game.particles[i].render(); + game.particles[i].die(); + if (game.particles[i].life < 0) { + game.particles.splice(i, 1) + } + } + } \ No newline at end of file