diff options
author | sanine <sanine.not@pm.me> | 2024-07-06 23:16:12 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2024-07-06 23:16:12 -0500 |
commit | 3499bfc152ab412c9becb51e1b29ba3ccfe8ac1d (patch) | |
tree | e4edd9fb3a3f186bbdffa338a337115b65338684 | |
parent | fdfa8561fbc884418bffa424876eb0e4e6756ecc (diff) |
add return button on level completion
-rw-r--r-- | level.js | 27 | ||||
-rw-r--r-- | levelSelect.js | 4 |
2 files changed, 23 insertions, 8 deletions
@@ -2,8 +2,8 @@ import { setupLevelSelectUi } from './levelSelect.js'; import { render } from './render.js'; -const X_START = '0.7t+sin(t)-6'; -const Y_START = '0.7t-6'; +const X_START = '0'; +const Y_START = 't'; const PATH_LEN = 20; const PATH_STEP = PATH_LEN/1000; @@ -218,7 +218,7 @@ function finishLevel(ui, level, fail) { } else { ui.sfx.doneAudio.currentTime = 0; ui.sfx.doneAudio.play(); - showAlert(ui, 'navigation successful: contract complete'); + showAlert(ui, 'navigation successful: contract complete', true); // ui.message.innerText = 'mission complete!'; level.completed = true; } @@ -226,7 +226,7 @@ function finishLevel(ui, level, fail) { } -function showAlert(ui, text) { +function showAlert(ui, text, ret) { const div = document.createElement('div'); div.classList.add('center-screen-container'); const div2 = document.createElement('div'); @@ -252,4 +252,23 @@ function showAlert(ui, text) { } p.appendChild(document.createElement('br')); p.appendChild(button); + + if (ret) { + const returnBtn = document.createElement('input'); + returnBtn.type = 'button'; + returnBtn.value = '↲ return'; + returnBtn.onmouseenter = () => { + ui.sfx.buttonEnterAudio.currentTime = 0; + ui.sfx.buttonEnterAudio.play(); + } + returnBtn.onclick = () => { + ui.sfx.buttonClickAudio.currentTime = 0; + ui.sfx.buttonClickAudio.play(); + ui.root.innerText = ''; + ui.root.classList.remove('center'); + window.onresize = () => {}; + setupLevelSelectUi(ui.root, ui.sfx); + } + p.appendChild(returnBtn); + } } diff --git a/levelSelect.js b/levelSelect.js index 9837a05..5e734c2 100644 --- a/levelSelect.js +++ b/levelSelect.js @@ -19,10 +19,6 @@ const levels = { ['parabolic 0'], buildLevel(t => -0.5*(t-3)**2 + 4, t => t-3, [...Array(8).keys()].map(x => x - 2)), ], - 'logarithmic': [ - ['parabolic 0'], - buildLevel(t => t-3, t => 4*Math.log(t), [...Array(8).keys()].map(x => x - 2)), - ], 'orbital': [ ['parabolic 0', 'sinusoidal'], buildLevel(t => 8*Math.cos(t), t => 8*Math.sin(t), [...Array(8).keys()].map(x => Math.PI * x / 4)), |