2023-12-07 13:45:22 +01:00
|
|
|
class Sound{
|
|
|
|
constructor(url){
|
|
|
|
this.assetsUrl = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadSounds(){
|
|
|
|
console.log(this.assetsUrl + "shoot.mp3")
|
|
|
|
this.shootSound = new Audio(this.assetsUrl + "shoot.mp3");
|
|
|
|
this.shootSound.type = "audio/mp3";
|
2023-12-07 18:53:44 +01:00
|
|
|
this.driftsound = new Audio(this.assetsUrl + "drift.mp3");
|
|
|
|
this.driftsound.type = "audio/mp3";
|
2023-12-07 13:45:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
shoot(){
|
|
|
|
this.shootSound.pause()
|
|
|
|
this.shootSound.currentTime=0;
|
|
|
|
this.shootSound.play()
|
|
|
|
}
|
2023-12-07 18:53:44 +01:00
|
|
|
|
|
|
|
drift(){
|
|
|
|
this.driftsound.pause()
|
|
|
|
this.driftsound.currentTime=0;
|
|
|
|
this.driftsound.play()
|
|
|
|
}
|
2023-12-07 13:45:22 +01:00
|
|
|
}
|