summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-06 23:16:12 -0500
committersanine <sanine.not@pm.me>2024-07-06 23:16:12 -0500
commit3499bfc152ab412c9becb51e1b29ba3ccfe8ac1d (patch)
treee4edd9fb3a3f186bbdffa338a337115b65338684 /level.js
parentfdfa8561fbc884418bffa424876eb0e4e6756ecc (diff)
add return button on level completion
Diffstat (limited to 'level.js')
-rw-r--r--level.js27
1 files changed, 23 insertions, 4 deletions
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);
+ }
}