Split The code is public; the app answers only to the crew.
A radar in the corner: the map, your team, the sites and the bomb #23
Check · Review · Land · Live done — Landed and live in production.
Adds a radar to the HUD: your team, the bomb once it's planted, and both sites (A/B), rotated so your view's yaw points up. Never the enemy.
shipped merged
commented
Merged main (the footsteps/sound-panning commit #22) into this branch. The only conflict was in README.md's module list, where both sides had added a new module to the same sentence — resolved by keeping both radar and ears in the list. Rebuilt static/app.<hash>.js against the merged sources and confirmed bun test passes (178 tests, up from 171 with the merged-in footstep tests). Pushed the merge commit.
Sign in to join this conversation.
new above
offline
Adds a radar to the HUD: your team, the bomb once it's planted, and both sites (A/B), rotated so your view's yaw points up. Never the enemy.
What changed
src/client/radar.ts(new): a pure functionbuildRadar(world, view, radius)that turns the world into a list of blips in canvas-ready axes (−1..1, +x right, +y down), rotated by the view's yaw. Only the view's own team, the planted bomb, and the two sites — enemies are structurally excluded. A teammate beyondradiusis dropped (not clamped), which is whatradar.test.tschecks along with the rotation math (north-facing vs. east-facing), the person always at the centre, and the bomb only blipping once planted.src/client/hud.ts: draws the radar bottom-left, clear of the money line, kill feed and clock. The walkable-cell map is baked once into an offscreen canvas (OffscreenCanvas, falling back todocument.createElementwhere available, and skipped gracefully in the headless test environment) and turned each frame withctx.rotate/ctx.translateinstead of re-walking the 1,936 cells — same caching pattern as the existing hurt vignette, rebuilt only when the on-screen size changes.src/client/hud.test.ts: extended the recording canvas mock withclip/translate/rotate/drawImage, tightened a few existing assertions that were counting all arcs/moveTos (now the radar adds its own), and added a test that the radar sits bottom-left and labels both sites.README.md: documents the radar in the HUD section and the module list.A real bug caught along the way: wiring the rotation in, I found
hud.tsalready had a localconst rad = Math.PI / 180(a degrees→radians multiplier) that would have silently shadowed therad()function I imported frommath.ts— calling a number as a function on every frame in any real browser, invisible in tests only becauseOffscreenCanvas/documentaren't defined there. Fixed by dropping the local constant and using the importedrad()at both existing call sites; verified the fix explicitly by stubbingOffscreenCanvasand runningdrawHudend-to-end outside the test file.Left out: I couldn't measure real frame time before/after — this sandbox has no GPU or browser (no
OffscreenCanvas, no Chromium available to launch headless), so I can't report actual fps numbers on "the same machine" as asked. The added draw work is a dozen smallfillRect/arc/fillTextcalls plus onedrawImageof a small cached bitmap, which should be negligible next to the existing scoreboard/kill-feed text, but that's reasoning, not a measurement — flagging it rather than guessing numbers.To try: run the game, the radar is bottom-left; turn and watch it rotate under your teammates' dots; plant the bomb and it shows up on the radar; nothing from the enemy team ever appears on it.
bun testpasses (171 tests).Closes #18