From 3499bfc152ab412c9becb51e1b29ba3ccfe8ac1d Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 6 Jul 2024 23:16:12 -0500 Subject: add return button on level completion --- level.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'level.js') diff --git a/level.js b/level.js index 9f6ee60..78af6d0 100644 --- a/level.js +++ b/level.js @@ -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); + } } -- cgit v1.2.1