feat: add audio features and sounds to the game #197

Merged
jleibl merged 3 commits from task/CAS-78/AddSoundEffects into main 2025-05-15 12:15:23 +00:00
Showing only changes of commit 566ea569e1 - Show all commits

View file

@ -7,13 +7,14 @@ export class AudioService {
private audioCache = new Map<string, HTMLAudioElement>();
private getAudio(soundName: string): HTMLAudioElement {
if (!this.audioCache.has(soundName)) {
const audio = new Audio(`/sounds/${soundName}`);
if (this.audioCache.has(soundName)) {
return this.audioCache.get(soundName)!;
}
const audio = new Audio(`/sounds/${soundName}.mp3`);
this.audioCache.set(soundName, audio);
return audio;
}
return this.audioCache.get(soundName)!;
}
playBetSound(): void {
const audio = this.getAudio('bet.mp3');