diff options
author | sanine <sanine.not@pm.me> | 2024-07-05 23:25:23 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2024-07-05 23:25:23 -0500 |
commit | aad68d877531ebdfb117a90c77ea7e538d858f2a (patch) | |
tree | d49e644cddea73ea10bb944390f73690b1b6d824 /level.js | |
parent | 7e2cc59135c1bc0036c4a3a9c91defef274f005e (diff) |
implement resource collection
Diffstat (limited to 'level.js')
-rw-r--r-- | level.js | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -98,7 +98,21 @@ export function setupLevelUi(level, root, audio) { function stepLevel(ui, level, index) { render(ui.ctx, level, index); + const pos = level.path[index]; + const distances = level.resources + .map((x, i) => [x, i]) + .filter(([x, _]) => x.collected === false) + .map(([x, i]) => [ distance(pos, x.position), i ]) + .forEach(([d, i]) => { + console.log(d); + if (d < 0.4) { + level.resources[i].collected = true; + } + }); + + + if (distance(pos, level.home) < 0.4) { level.running = false; ui.rocketGain.gain.setTargetAtTime(0, ui.audio.currentTime, FAST_RAMP); |