summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-06 18:41:43 -0500
committersanine <sanine.not@pm.me>2024-07-06 18:41:43 -0500
commit0c6831d63cfb6b98107826524183d444eee2e4bd (patch)
tree62a8f839ffd2e50cd4d5aed07732f5eec9964327 /level.js
parent1611ea0b88044bc6bc98ddd1d7dc9d6011b7f05c (diff)
add alerts
Diffstat (limited to 'level.js')
-rw-r--r--level.js40
1 files changed, 36 insertions, 4 deletions
diff --git a/level.js b/level.js
index ba1032f..5a20ef5 100644
--- a/level.js
+++ b/level.js
@@ -32,7 +32,7 @@ export function setupLevel(resources, home) {
export function setupLevelUi(level, root, sfx) {
- const ui = { sfx };
+ const ui = { root, sfx };
root.classList.add('center');
ui.launchButton = document.createElement('input');
@@ -187,16 +187,48 @@ function finishLevel(ui, level, fail) {
if (fail) {
ui.sfx.wrongAudio.currentTime = 0;
ui.sfx.wrongAudio.play();
- ui.message.innerText = 'did not arrive at destination';
+ showAlert(ui, 'trajectory does not reach AMH processor');
+ // ui.message.innerText = 'did not arrive at destination';
} else if (uncollected > 0) {
ui.sfx.wrongAudio.currentTime = 0;
ui.sfx.wrongAudio.play();
- ui.message.innerText = 'resources remaining!';
+ showAlert(ui, 'monopole harvesting failure');
+ // ui.message.innerText = 'resources remaining!';
} else {
ui.sfx.doneAudio.currentTime = 0;
ui.sfx.doneAudio.play();
- ui.message.innerText = 'mission complete!';
+ showAlert(ui, 'navigation successful: contract complete');
+ // ui.message.innerText = 'mission complete!';
level.completed = true;
}
level.resources.forEach(x => x.collected = false);
}
+
+
+function showAlert(ui, text) {
+ const div = document.createElement('div');
+ div.classList.add('center-screen-container');
+ const div2 = document.createElement('div');
+ div2.classList.add('center-screen');
+ div.appendChild(div2);
+ const p = document.createElement('p');
+ p.classList.add('alert-box');
+ p.innerText = text;
+ div2.appendChild(p);
+ ui.root.appendChild(div);
+
+ const button = document.createElement('input');
+ button.type = 'button';
+ button.value = 'OK';
+ button.onmouseenter = () => {
+ ui.sfx.buttonEnterAudio.currentTime = 0;
+ ui.sfx.buttonEnterAudio.play();
+ }
+ button.onclick = () => {
+ ui.sfx.buttonClickAudio.currentTime = 0;
+ ui.sfx.buttonClickAudio.play();
+ ui.root.removeChild(div);
+ }
+ p.appendChild(document.createElement('br'));
+ p.appendChild(button);
+}