diff options
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); |