promise
This commit is contained in:
parent
90df10e141
commit
e97c535fc6
10
app.js
10
app.js
@ -438,13 +438,13 @@ let midiSong
|
||||
let noteSprites = []
|
||||
let explosionSprites = []
|
||||
let health
|
||||
async function nextLevel(time=0) {
|
||||
function nextLevel(time=0) {
|
||||
Tone.Transport.pause()
|
||||
level++
|
||||
if (level <= MAX_LEVEL) {
|
||||
midiSong = Midi.fromUrl(`midi/${level}.mid`).then((midi) => {
|
||||
midiSong = midi
|
||||
health = 12
|
||||
batterySprite.frame = health
|
||||
midiSong = await Midi.fromUrl(`midi/${level}.mid`)
|
||||
levelTitle.innerText = `Niveau ${level}`
|
||||
songNameTitle.innerText = midiSong.name
|
||||
noteSprites = []
|
||||
@ -463,9 +463,9 @@ async function nextLevel(time=0) {
|
||||
Tone.Transport.scheduleOnce(time => nextLevel(time), time + midiSong.duration + TIME_TO_SCREEN)
|
||||
|
||||
levelDialog.showModal()
|
||||
} else {
|
||||
}).catch((error) => {
|
||||
victory(time)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
levelDialog.onclose = resume
|
||||
|
Loading…
x
Reference in New Issue
Block a user