Skip to content

Commit 4496dcd

Browse files
committed
sound
1 parent 836ea6c commit 4496dcd

File tree

7 files changed

+6
-4
lines changed

7 files changed

+6
-4
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
<button class="start">Start</button>
136136
</div>
137137
</div>
138+
<audio src="hit.wav" id="hit-audio"></audio>
139+
<audio src="hurt.wav" id="hurt-audio"></audio>
140+
<audio src="powerup.wav" id="powerup-audio"></audio>
138141
<script type="module" src="/src/main.ts"></script>
139142
</body>
140143
</html>

public/hit.wav

1022 Bytes
Binary file not shown.

public/hurt.wav

1.73 KB
Binary file not shown.

public/powerup.wav

6.1 KB
Binary file not shown.

src/components/death.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ export class DeathRenderComponent extends BaseComponent implements Renderer {
2727

2828
start() {
2929
this.transform = COMPONENTS[this.entity]["transform"];
30-
if (!this.transform) {
31-
console.error(`no transform component on ${this.entity}`);
32-
}
3330
}
3431

3532
render(ctx: CanvasRenderingContext2D) {
@@ -147,6 +144,7 @@ export class PlayerCollider extends Collider implements ICollider {
147144
COMPONENTS.player.collider!.collidingWith.delete(e);
148145
delete COMPONENTS[e];
149146
GAME.score += 1;
147+
(document.querySelector("#hit-audio") as HTMLAudioElement).play();
150148

151149
if (
152150
Object.keys(COMPONENTS).filter((x) => x.startsWith("npc"))
@@ -158,6 +156,7 @@ export class PlayerCollider extends Collider implements ICollider {
158156

159157
if (!npcLife.living && this.enabled) {
160158
this.playerHealth!.hearts -= 1;
159+
(document.querySelector("#hurt-audio") as HTMLAudioElement).play();
161160
if (this.playerHealth!.hearts === 0) {
162161
this.enabled = false;
163162
GAME.screen = "uded";

src/components/door.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class DoorCollider extends Collider implements ICollider {
1111
for (const e of entities) {
1212
if (e === "player") {
1313
GAME.level += 1;
14+
(document.querySelector("#powerup-audio") as HTMLAudioElement).play();
1415
}
1516
}
1617
}

src/game.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class Game {
123123

124124
countdown(deltaTime: number) {
125125
if (this.screen !== "game") return;
126-
console.log("hello?");
127126
if (this.waitingForStart === 0) return;
128127

129128
ctx.fillStyle = "white";

0 commit comments

Comments
 (0)