diff options
20 files changed, 87 insertions, 23 deletions
@@ -7,13 +7,14 @@ <script src="mathjs/mathjs-expression-parser.js"></script> </head> <body> - <h1 id="status">⚠ WARNING</h1> <audio id="music-starboard" src="sounds/music/starboard.mp3"></audio> <audio id="music-minute" src="sounds/music/minute.mp3"></audio> <audio id="music-cribwhistling" src="sounds/music/cribwhistling.mp3"></audio> <audio id="music-swish" src="sounds/music/swish.mp3"></audio> <audio id="music-aeroplane" src="sounds/music/aeroplane.mp3"></audio> - <audio id="sfx-rocket-thrust" src="sounds/sfx/ship_move.mp3" loop="true"></audio> + <audio id="sfx-resource" src="sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav"></audio> + <audio id="sfx-done" src="sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav"></audio> + <audio id="sfx-wrong" src="sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav"></audio> <div id="root"></div> </body> </html> @@ -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; } @@ -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 Binary files differnew file mode 100644 index 0000000..dcaf90b --- /dev/null +++ b/sounds/sfx/gui-beep/2120__jobro__futuristic-gui-beeps.zip diff --git a/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav b/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav Binary files differnew file mode 100644 index 0000000..4a37004 --- /dev/null +++ b/sounds/sfx/gui-beep/33775__jobro__1-beep-a.wav diff --git a/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav b/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav Binary files differnew file mode 100644 index 0000000..c73f3a9 --- /dev/null +++ b/sounds/sfx/gui-beep/33776__jobro__1-beep-b.wav diff --git a/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav b/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav Binary files differnew file mode 100644 index 0000000..87560d1 --- /dev/null +++ b/sounds/sfx/gui-beep/33777__jobro__1-beep-c.wav diff --git a/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav b/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav Binary files differnew file mode 100644 index 0000000..b99f2e3 --- /dev/null +++ b/sounds/sfx/gui-beep/33778__jobro__2-beep-a.wav diff --git a/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav b/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav Binary files differnew file mode 100644 index 0000000..7df86b5 --- /dev/null +++ b/sounds/sfx/gui-beep/33779__jobro__2-beep-b.wav diff --git a/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav b/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav Binary files differnew file mode 100644 index 0000000..7e82010 --- /dev/null +++ b/sounds/sfx/gui-beep/33780__jobro__2-beep-c.wav diff --git a/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav b/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav Binary files differnew file mode 100644 index 0000000..787c98e --- /dev/null +++ b/sounds/sfx/gui-beep/33781__jobro__3-beep-a.wav diff --git a/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav b/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav Binary files differnew file mode 100644 index 0000000..0f19cda --- /dev/null +++ b/sounds/sfx/gui-beep/33782__jobro__3-beep-b.wav diff --git a/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav b/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav Binary files differnew file mode 100644 index 0000000..47f5e91 --- /dev/null +++ b/sounds/sfx/gui-beep/33783__jobro__3-beep-c.wav diff --git a/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav b/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav Binary files differnew file mode 100644 index 0000000..c8427a9 --- /dev/null +++ b/sounds/sfx/gui-beep/33784__jobro__4-beep-a.wav diff --git a/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav b/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav Binary files differnew file mode 100644 index 0000000..28f98c0 --- /dev/null +++ b/sounds/sfx/gui-beep/33785__jobro__4-beep-b.wav diff --git a/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav b/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav Binary files differnew file mode 100644 index 0000000..bce6d29 --- /dev/null +++ b/sounds/sfx/gui-beep/33786__jobro__4-beep-c.wav diff --git a/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav b/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav Binary files differnew file mode 100644 index 0000000..d911bc8 --- /dev/null +++ b/sounds/sfx/gui-beep/33787__jobro__5-beep-a.wav diff --git a/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav b/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav Binary files differnew file mode 100644 index 0000000..22fc1cf --- /dev/null +++ b/sounds/sfx/gui-beep/33788__jobro__5-beep-b.wav diff --git a/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav b/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav Binary files differnew file mode 100644 index 0000000..cdcfbd6 --- /dev/null +++ b/sounds/sfx/gui-beep/33789__jobro__5-beep-c.wav 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 + + |