summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
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);