diff options
author | sanine <sanine.not@pm.me> | 2024-07-06 20:16:48 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2024-07-06 20:16:48 -0500 |
commit | 03528a25215330d3b00cabdb1bbe7ce701e1bfeb (patch) | |
tree | caaed47028b8985137afdf5a9416f9e4c4de3db3 /level.js | |
parent | 0c6831d63cfb6b98107826524183d444eee2e4bd (diff) |
implement level loading animation
Diffstat (limited to 'level.js')
-rw-r--r-- | level.js | 46 |
1 files changed, 32 insertions, 14 deletions
@@ -37,7 +37,7 @@ export function setupLevelUi(level, root, sfx) { root.classList.add('center'); ui.launchButton = document.createElement('input'); ui.launchButton.type = 'button'; - ui.launchButton.value = 'Launch'; + ui.launchButton.value = 'launch'; ui.launchButton.onmouseenter = () => { sfx.buttonEnterAudio.currentTime = 0; sfx.buttonEnterAudio.play(); @@ -88,18 +88,29 @@ export function setupLevelUi(level, root, sfx) { ui.message = document.createElement('div'); ui.id = "level-message"; - root.appendChild(ui.xeqLabel); - root.appendChild(ui.xeq); - root.appendChild(document.createElement('br')); - root.appendChild(ui.yeqLabel); - root.appendChild(ui.yeq); - root.appendChild(document.createElement('br')); - root.appendChild(ui.launchButton); - root.appendChild(ui.message); + const appearSound = () => { sfx.listAppearAudio.currentTime = 0; sfx.listAppearAudio.play(); }; + setTimeout(() => { + root.appendChild(ui.xeqLabel); + root.appendChild(ui.xeq); + root.appendChild(document.createElement('br')); + appearSound(); + }, 100); + setTimeout(() => { + root.appendChild(ui.yeqLabel); + root.appendChild(ui.yeq); + root.appendChild(document.createElement('br')); + appearSound(); + }, 200); + setTimeout(() => { + root.appendChild(ui.launchButton); + root.appendChild(ui.message); + appearSound(); + }, 300); ui.canvas = document.createElement('canvas'); + ui.canvas.classList.add('bordered'); const setCanvasSize = () => { - const size = Math.min(0.7*window.innerHeight, 0.9*root.offsetWidth); + const size = Math.min(0.8*window.innerHeight, 0.9*root.offsetWidth); ui.canvas.width = size; ui.canvas.height = size; ui.ctx = ui.canvas.getContext('2d'); @@ -109,12 +120,16 @@ export function setupLevelUi(level, root, sfx) { } setCanvasSize(); window.onresize = setCanvasSize; - root.appendChild(ui.canvas); - root.appendChild(document.createElement('br')); + setTimeout(() => { + root.appendChild(ui.canvas); + root.appendChild(document.createElement('br')); + appearSound(); + }, 400); + ui.returnBtn = document.createElement('input'); ui.returnBtn.type = 'button'; - ui.returnBtn.value = '↲ Return'; + ui.returnBtn.value = '↲ return'; ui.returnBtn.onmouseenter = () => { sfx.buttonEnterAudio.currentTime = 0; sfx.buttonEnterAudio.play(); @@ -127,7 +142,10 @@ export function setupLevelUi(level, root, sfx) { window.onresize = () => {}; setupLevelSelectUi(root, sfx); } - root.appendChild(ui.returnBtn); + setTimeout(() => { + root.appendChild(ui.returnBtn); + appearSound(); + }, 500); return ui; } |