feat: add audio features and sounds to the game #197
1 changed files with 6 additions and 5 deletions
|
@ -7,13 +7,14 @@ export class AudioService {
|
||||||
private audioCache = new Map<string, HTMLAudioElement>();
|
private audioCache = new Map<string, HTMLAudioElement>();
|
||||||
|
|
||||||
private getAudio(soundName: string): HTMLAudioElement {
|
private getAudio(soundName: string): HTMLAudioElement {
|
||||||
if (!this.audioCache.has(soundName)) {
|
if (this.audioCache.has(soundName)) {
|
||||||
const audio = new Audio(`/sounds/${soundName}`);
|
return this.audioCache.get(soundName)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
const audio = new Audio(`/sounds/${soundName}.mp3`);
|
||||||
this.audioCache.set(soundName, audio);
|
this.audioCache.set(soundName, audio);
|
||||||
return audio;
|
return audio;
|
||||||
}
|
}
|
||||||
return this.audioCache.get(soundName)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
playBetSound(): void {
|
playBetSound(): void {
|
||||||
const audio = this.getAudio('bet.mp3');
|
const audio = this.getAudio('bet.mp3');
|
||||||
|
|
Reference in a new issue