From 9b2bed395c82bc1644ef86a096f33b876358af40 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 6 Jul 2024 01:02:17 -0500 Subject: add better ui sounds and remove rocket sound --- index.html | 5 +- level.js | 33 +++++----- main.js | 5 -- .../gui-beep/2120__jobro__futuristic-gui-beeps.zip | Bin 0 -> 4543416 bytes sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav | Bin 0 -> 302594 bytes sounds/sfx/gui-beep/_readme_and_license.txt | 67 +++++++++++++++++++++ 20 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 sounds/sfx/gui-beep/2120__jobro__futuristic-gui-beeps.zip create mode 100644 sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav create mode 100644 sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav create mode 100644 sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav create mode 100644 sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav create mode 100644 sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav create mode 100644 sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav create mode 100644 sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav create mode 100644 sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav create mode 100644 sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav create mode 100644 sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav create mode 100644 sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav create mode 100644 sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav create mode 100644 sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav create mode 100644 sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav create mode 100644 sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav create mode 100644 sounds/sfx/gui-beep/_readme_and_license.txt diff --git a/index.html b/index.html index f5e66d7..b889a4a 100644 --- a/index.html +++ b/index.html @@ -7,13 +7,14 @@ -

⚠ WARNING

- + + +
diff --git a/level.js b/level.js index d511fa7..e2018e2 100644 --- a/level.js +++ b/level.js @@ -31,11 +31,17 @@ export function setupLevel(resources, home) { export function setupLevelUi(level, root, audio) { const ui = { audio }; - ui.rocketThrustAudio = document.getElementById('sfx-rocket-thrust'); - ui.rocketThrustSource = audio.createMediaElementSource(ui.rocketThrustAudio); - ui.rocketGain = audio.createGain(); - ui.rocketGain.gain.value = 0; - ui.rocketThrustSource.connect(ui.rocketGain).connect(audio.destination); + ui.resourceAudio = document.getElementById('sfx-resource'); + ui.resourceSource = audio.createMediaElementSource(ui.resourceAudio); + ui.resourceSource.connect(audio.destination); + + ui.doneAudio = document.getElementById('sfx-done'); + ui.doneSource = audio.createMediaElementSource(ui.doneAudio); + ui.doneSource.connect(audio.destination); + + ui.wrongAudio = document.getElementById('sfx-wrong'); + ui.wrongSource = audio.createMediaElementSource(ui.wrongAudio); + ui.wrongSource.connect(audio.destination); ui.launchButton = document.createElement('input'); ui.launchButton.type = 'button'; @@ -43,16 +49,12 @@ export function setupLevelUi(level, root, audio) { ui.launchButton.onclick = () => { ui.message.innerText = ''; level.running = false; - ui.rocketThrustAudio.play(); - ui.rocketGain.gain.setTargetAtTime(1, audio.currentTime, FAST_RAMP); setTimeout(() => { level.running=true; stepLevel(ui, level, 0); }, 20); } ui.xeq = document.createElement('input'); ui.xeq.value = X_START; ui.xeq.onchange = (e) => { - ui.rocketGain.gain.setTargetAtTime(0, audio.currentTime, FAST_RAMP); - setTimeout(() => ui.rocketThrustAudio.pause(), 50); level.equations.x = math.compile(e.target.value); level.running = false; level.path = computePath(level.equations); @@ -64,8 +66,6 @@ export function setupLevelUi(level, root, audio) { ui.yeq = document.createElement('input'); ui.yeq.value = Y_START; ui.yeq.onchange = (e) => { - ui.rocketGain.gain.setTargetAtTime(0, audio.currentTime, FAST_RAMP); - setTimeout(() => ui.rocketThrustAudio.pause(), 50); level.equations.y = math.compile(e.target.value); level.running = false; level.path = computePath(level.equations); @@ -105,8 +105,9 @@ function stepLevel(ui, level, index) { .filter(([x, _]) => x.collected === false) .map(([x, i]) => [ distance(pos, x.position), i ]) .forEach(([d, i]) => { - console.log(d); if (d < 0.4) { + ui.resourceAudio.load(); + ui.resourceAudio.play(); level.resources[i].collected = true; } }); @@ -115,16 +116,12 @@ function stepLevel(ui, level, index) { if (distance(pos, level.home) < 0.4) { level.running = false; - ui.rocketGain.gain.setTargetAtTime(0, ui.audio.currentTime, FAST_RAMP); - setTimeout(() => ui.rocketThrustAudio.pause(), 50); finishLevel(ui, level); render(ui.ctx, level, 0); } else if (level.running && index < level.path.length-1) { setTimeout(() => stepLevel(ui, level, index+1), 1); } else { level.running = false; - ui.rocketGain.gain.setTargetAtTime(0, ui.audio.currentTime, FAST_RAMP); - setTimeout(() => ui.rocketThrustAudio.pause(), 50); render(ui.ctx, level, 0); } } @@ -146,8 +143,12 @@ function distance(p1, p2) { function finishLevel(ui, level) { const uncollected = level.resources.reduce((acc, { collected }) => acc + (collected ? 0 : 1), 0); if (uncollected > 0) { + ui.wrongAudio.load(); + ui.wrongAudio.play(); ui.message.innerText = 'resources remaining!'; } else { + ui.doneAudio.load(); + ui.doneAudio.play(); ui.message.innerText = 'mission complete!'; level.completed = true; } diff --git a/main.js b/main.js index 107c580..7ce6e6f 100644 --- a/main.js +++ b/main.js @@ -11,11 +11,6 @@ window.onload = () => { const audio = new AudioContext(); root.removeChild(start); - const rocketThrustAudio = document.getElementById('sfx-rocket-thrust'); - const rocketThrustSource = audio.createMediaElementSource(rocketThrustAudio); - const rocketGain = audio.createGain(); - rocketThrustSource.connect(rocketGain).connect(audio.destination); - const musicGain = audio.createGain(); const addMusic = (music, id) => { const element = document.getElementById(id); diff --git a/sounds/sfx/gui-beep/2120__jobro__futuristic-gui-beeps.zip b/sounds/sfx/gui-beep/2120__jobro__futuristic-gui-beeps.zip new file mode 100644 index 0000000..dcaf90b Binary files /dev/null and b/sounds/sfx/gui-beep/2120__jobro__futuristic-gui-beeps.zip differ diff --git a/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav b/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav new file mode 100644 index 0000000..4a37004 Binary files /dev/null and b/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav differ diff --git a/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav b/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav new file mode 100644 index 0000000..c73f3a9 Binary files /dev/null and b/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav differ diff --git a/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav b/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav new file mode 100644 index 0000000..87560d1 Binary files /dev/null and b/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav differ diff --git a/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav b/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav new file mode 100644 index 0000000..b99f2e3 Binary files /dev/null and b/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav differ diff --git a/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav b/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav new file mode 100644 index 0000000..7df86b5 Binary files /dev/null and b/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav differ diff --git a/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav b/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav new file mode 100644 index 0000000..7e82010 Binary files /dev/null and b/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav differ diff --git a/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav b/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav new file mode 100644 index 0000000..787c98e Binary files /dev/null and b/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav differ diff --git a/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav b/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav new file mode 100644 index 0000000..0f19cda Binary files /dev/null and b/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav differ diff --git a/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav b/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav new file mode 100644 index 0000000..47f5e91 Binary files /dev/null and b/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav differ diff --git a/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav b/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav new file mode 100644 index 0000000..c8427a9 Binary files /dev/null and b/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav differ diff --git a/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav b/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav new file mode 100644 index 0000000..28f98c0 Binary files /dev/null and b/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav differ diff --git a/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav b/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav new file mode 100644 index 0000000..bce6d29 Binary files /dev/null and b/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav differ diff --git a/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav b/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav new file mode 100644 index 0000000..d911bc8 Binary files /dev/null and b/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav differ diff --git a/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav b/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav new file mode 100644 index 0000000..22fc1cf Binary files /dev/null and b/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav differ diff --git a/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav b/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav new file mode 100644 index 0000000..cdcfbd6 Binary files /dev/null and b/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav differ diff --git a/sounds/sfx/gui-beep/_readme_and_license.txt b/sounds/sfx/gui-beep/_readme_and_license.txt new file mode 100644 index 0000000..91e080d --- /dev/null +++ b/sounds/sfx/gui-beep/_readme_and_license.txt @@ -0,0 +1,67 @@ +Sound pack downloaded from Freesound +---------------------------------------- + +"Futuristic GUI beeps" + +This pack of sounds contains sounds by the following user: + - jobro ( https://freesound.org/people/jobro/ ) + +You can find this pack online at: https://freesound.org/people/jobro/packs/2120/ + + +Licenses in this pack (see below for individual sound licenses) +--------------------------------------------------------------- + +Attribution 3.0: http://creativecommons.org/licenses/by/3.0/ + + +Sounds in this pack +------------------- + + * 33789__jobro__5_beep_c.wav + * url: https://freesound.org/s/33789/ + * license: Attribution 3.0 + * 33788__jobro__5_beep_b.wav + * url: https://freesound.org/s/33788/ + * license: Attribution 3.0 + * 33787__jobro__5_beep_a.wav + * url: https://freesound.org/s/33787/ + * license: Attribution 3.0 + * 33786__jobro__4_beep_c.wav + * url: https://freesound.org/s/33786/ + * license: Attribution 3.0 + * 33785__jobro__4_beep_b.wav + * url: https://freesound.org/s/33785/ + * license: Attribution 3.0 + * 33784__jobro__4_beep_a.wav + * url: https://freesound.org/s/33784/ + * license: Attribution 3.0 + * 33783__jobro__3_beep_c.wav + * url: https://freesound.org/s/33783/ + * license: Attribution 3.0 + * 33782__jobro__3_beep_b.wav + * url: https://freesound.org/s/33782/ + * license: Attribution 3.0 + * 33781__jobro__3_beep_a.wav + * url: https://freesound.org/s/33781/ + * license: Attribution 3.0 + * 33780__jobro__2_beep_c.wav + * url: https://freesound.org/s/33780/ + * license: Attribution 3.0 + * 33779__jobro__2_beep_b.wav + * url: https://freesound.org/s/33779/ + * license: Attribution 3.0 + * 33778__jobro__2_beep_a.wav + * url: https://freesound.org/s/33778/ + * license: Attribution 3.0 + * 33777__jobro__1_beep_c.wav + * url: https://freesound.org/s/33777/ + * license: Attribution 3.0 + * 33776__jobro__1_beep_b.wav + * url: https://freesound.org/s/33776/ + * license: Attribution 3.0 + * 33775__jobro__1_beep_a.wav + * url: https://freesound.org/s/33775/ + * license: Attribution 3.0 + + -- cgit v1.2.1