Skip to content

Add speed boost pickups - #5

Open
pbardocz wants to merge 1 commit into
mainfrom
feature/speed-boost
Open

pbardocz wants to merge 1 commit into
mainfrom
feature/speed-boost

Conversation

@pbardocz

@pbardocz pbardocz commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add collectible speed boost pickups scattered around the map that give the player's vehicle a temporary top-speed multiplier.

Changes

  • Add a boosts array of pickup locations, spawned along roads via the existing roadPoint() helper
  • Add checkBoosts() to detect pickup and grant player.boost duration
  • Apply a 1.6x top-speed multiplier in driveVehicle() while a boost is active, decrementing the timer each frame
  • Draw pickups on the map with a pulsing cyan marker

Testing

  1. Open index.html in a browser
  2. Start a game, get in a vehicle
  3. Drive over one of the cyan pickups — a "Speed boost!" toast should appear and the vehicle should noticeably accelerate further before topping out

Scatter glowing pickups around the map; driving through one grants a
temporary top-speed multiplier for the vehicle.
@vincentiusdegroot

Copy link
Copy Markdown
Owner

Review: Speed Boost Pickups

Great feature! The gameplay logic is solid. However, there's a bug in the canvas drawing that needs fixing before merge.

Critical Issue: Arc Angle Parameters

In drawBoost(), the arc angles are set to 7 instead of Math.PI * 2:

The canvas arc() function expects angles in radians (0 to 2π ≈ 6.28). Using 7 causes the arcs to be drawn incorrectly and won't produce the intended circular glow effect.

Lines to fix:

  • Line 1363: g.arc(0, 0, 20 * pulse, 0, 7)g.arc(0, 0, 20 * pulse, 0, Math.PI * 2)
  • Line 1367: g.arc(0, 0, 14, 0, 7)g.arc(0, 0, 14, 0, Math.PI * 2)

Good Implementation Notes

✅ Boost timer correctly decrements by dt each frame
✅ Top speed multiplier properly applies in forward and reverse
✅ Pickup spawning and touch detection logic is solid
✅ Creative visual design with pulsing effect

Fix the arc angles and this is ready to merge!

@pbardocz pbardocz left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional review notes

Confirmed the arc-angle issue already flagged in the comment above (7 vs Math.PI * 2 at index.html:1363/1367) — agreed, that should be fixed before merge.

A few more things worth a look:

  1. Boost only decays while driving. player.boost -= dt lives inside driveVehicle() (index.html:1057), but checkBoosts() runs every frame regardless of whether the player is on foot or in a car (index.html:1547). Walking over a pickup sets player.boost = 240 and it just sits there — undecayed — until the player next gets in a vehicle, however long that takes. Is a "banked" boost the intended design, or should the timer start counting down from the moment of pickup regardless of vehicle state?

  2. Reverse speed also gets boosted. topSpeed multiplies both the forward clamp and the reverse clamp (-topSpeed * 0.42, index.html:1036), so boost pickups make reversing 1.6x faster too. Probably harmless, but worth confirming it's intentional.

  3. No feedback once the toast fades. The "Speed boost!" toast lasts 170 ticks (toast(), index.html:961) but the boost itself lasts 240 ticks (BOOST_DURATION), so there's a ~70-tick window where the player still has the speed boost but no on-screen indication of it. A small always-on indicator (HUD icon, vehicle glow, etc.) while player.boost > 0 would close that gap.

  4. No test coverage. Per CLAUDE.md this repo's only test is a static check on index.html's script (tests/test_render_mini.py) — it still passes here, but nothing exercises the new pickup/decay/multiplier logic even at the level this repo's test style allows (e.g. a static check that checkBoosts() is called from the main loop, mirroring the existing renderMini liveness check).

  5. Nit: drawBoost() isn't culled by the vis() viewport check the other entities use before drawing (index.html:1402-ish) — trivial with only 5 pickups on the map, but worth keeping in mind if the pickup count ever grows.

Otherwise the core mechanic (spawn → pickup → toast → respawn, multiplier clamp) looks correct and matches the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants