summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-05 23:25:23 -0500
committersanine <sanine.not@pm.me>2024-07-05 23:25:23 -0500
commitaad68d877531ebdfb117a90c77ea7e538d858f2a (patch)
treed49e644cddea73ea10bb944390f73690b1b6d824 /level.js
parent7e2cc59135c1bc0036c4a3a9c91defef274f005e (diff)
implement resource collection
Diffstat (limited to 'level.js')
-rw-r--r--level.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/level.js b/level.js
index c10139c..d511fa7 100644
--- a/level.js
+++ b/level.js
@@ -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);