summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-06 12:09:59 -0500
committersanine <sanine.not@pm.me>2024-07-06 12:09:59 -0500
commit2a2dadfb9739874044bdcc20cf6152115a04bc07 (patch)
tree38fd82a28d6cdf979f2b5e613a39e3f0fbb15341 /level.js
parent2f300a221b850ae66a785523436511c06b318a22 (diff)
add button sfx
Diffstat (limited to 'level.js')
-rw-r--r--level.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/level.js b/level.js
index 27b7078..5671c4c 100644
--- a/level.js
+++ b/level.js
@@ -32,6 +32,11 @@ export function setupLevel(resources, home) {
export function setupLevelUi(level, root, audio) {
const ui = { audio };
+ const buttonEnterAudio = document.getElementById('sfx-buttonenter');
+ const buttonClickAudio = document.getElementById('sfx-buttonclick');
+ audio.createMediaElementSource(buttonEnterAudio).connect(audio.destination);
+ audio.createMediaElementSource(buttonClickAudio).connect(audio.destination);
+
ui.resourceAudio = document.getElementById('sfx-resource');
ui.resourceSource = audio.createMediaElementSource(ui.resourceAudio);
ui.resourceSource.connect(audio.destination);
@@ -47,7 +52,13 @@ export function setupLevelUi(level, root, audio) {
ui.launchButton = document.createElement('input');
ui.launchButton.type = 'button';
ui.launchButton.value = 'Launch';
+ ui.launchButton.onmouseenter = () => {
+ buttonEnterAudio.load();
+ buttonEnterAudio.play();
+ }
ui.launchButton.onclick = () => {
+ buttonClickAudio.load();
+ buttonClickAudio.play();
ui.message.innerText = '';
level.running = false;
setTimeout(() => { level.running=true; stepLevel(ui, level, 0); }, 20);
@@ -95,7 +106,13 @@ export function setupLevelUi(level, root, audio) {
ui.returnBtn = document.createElement('input');
ui.returnBtn.type = 'button';
ui.returnBtn.value = 'Return';
+ ui.returnBtn.onmouseenter = () => {
+ buttonEnterAudio.load();
+ buttonEnterAudio.play();
+ }
ui.returnBtn.onclick = () => {
+ buttonClickAudio.load();
+ buttonClickAudio.play();
root.innerText = '';
setupLevelSelectUi(root, audio);
}