feat: add audio features and sounds to the game #197
1 changed files with 6 additions and 5 deletions
|
@ -7,12 +7,13 @@ 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}`);
|
||||
this.audioCache.set(soundName, audio);
|
||||
return audio;
|
||||
if (this.audioCache.has(soundName)) {
|
||||
return this.audioCache.get(soundName)!;
|
||||
}
|
||||
return this.audioCache.get(soundName)!;
|
||||
|
||||
const audio = new Audio(`/sounds/${soundName}.mp3`);
|
||||
this.audioCache.set(soundName, audio);
|
||||
return audio;
|
||||
}
|
||||
|
||||
playBetSound(): void {
|
||||
|
|
Reference in a new issue