summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-27 18:30:10 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-27 18:30:10 +0100
commit0696b94962a0571fad54844f137dca025df4563b (patch)
tree8aeff72e8fc46a7dab2b2f556febd962e3f67e4b /src/engine
parent474a7253b6b67e2ed33936f6b633587d5d304b66 (diff)
game finished, only assets left
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/radio.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/engine/radio.js b/src/engine/radio.js
index d39524a..0e2abba 100644
--- a/src/engine/radio.js
+++ b/src/engine/radio.js
@@ -1,4 +1,17 @@
export class Radio {
+ playSound(file) {
+ let audio = new Audio(file)
+ audio.play()
+ }
+
+ playSoundUntilEnd(file) {
+ let audio = new Audio(file)
+ return new Promise(res => {
+ audio.play()
+ audio.onended = res
+ })
+ }
+
bgm
playMusic(file) {
if (this.bgm != undefined) this.bgm.pause()
@@ -7,8 +20,7 @@ export class Radio {
this.bgm.loop = true
}
- playSound(file) {
- let audio = new Audio(file)
- audio.play()
+ stopMusic() {
+ this.bgm.pause()
}
}