From 20b7944602626f19a538e976a57d1d344e10f71b Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Tue, 19 Apr 2022 16:51:15 -0600 Subject: Add music/sounds; fix a bug where you could attempt to resume a game when it was won --- src/systems/collision.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/systems/collision.js') diff --git a/src/systems/collision.js b/src/systems/collision.js index 013ae1e..0732c74 100644 --- a/src/systems/collision.js +++ b/src/systems/collision.js @@ -11,6 +11,7 @@ game.system.Collision = (entitiesGrid) => { burnedParticleSpawner.addComponent(game.components.Appearance({width: game.canvas.width / game.config.xDim, height: game.canvas.height / game.config.yDim})); game.entities[burnedParticleSpawner.id] = burnedParticleSpawner; entity.removeComponent("alive"); + game.assets.death.play(); break; } else if (entity.hasComponent("sinkable") && collided.hasComponent("sink")) { const sunkParticleSpawner = game.createBorderParticles({colors: ["#16f7c9", "#0d6e5a", "#2fa18a", "#48cfb4", "#58877d", "#178054", "#2cdb92"]}); @@ -19,6 +20,7 @@ game.system.Collision = (entitiesGrid) => { game.entities[sunkParticleSpawner.id] = sunkParticleSpawner; entity.removeComponent("alive"); collided.removeComponent("alive"); + game.assets.death.play(); break; } } @@ -27,6 +29,8 @@ game.system.Collision = (entitiesGrid) => { if (entity.hasComponent("controllable") && entity.hasComponent("gridPosition")) { for (let collided of entitiesGrid[entity.components.gridPosition.y][entity.components.gridPosition.x].values()) { if (collided.hasComponent("win")) { + game.assets.win.play(); + game.win = true; game.systems.menu.bringUpMenu(); game.systems.menu.setState("levelSelect"); } @@ -70,6 +74,7 @@ game.system.Collision = (entitiesGrid) => { if (wall) { entity.removeComponent("momentum"); } else { + game.assets.move.play(); entitiesToPush.map((e) => { const pushedParticleSpawner = game.createBorderParticles({maxSpeed: 0.1, minAmount: 10, maxAmount: 15}); pushedParticleSpawner.addComponent(game.components.Position(e.components.position)); -- cgit v1.2.3-70-g09d2