Split The code is public; the app answers only to the crew.

Who is that: a name over the player you can see, health when they are yours, and a `project.ts` that can place it #119

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

New src/client/project.ts is the piece nothing in the client had: project(point, camera, width, height) builds the renderer's own matrix — horizontal FOV turned vertical by the aspect, near 6 and far 12000 — and returns {x, y, depth} in canvas pixels, or null when there is no pixel for the point (behind the eye, inside…

Notes

shipped merged

opened this

New src/client/project.ts is the piece nothing in the client had: project(point, camera, width, height) builds the renderer's own matrix — horizontal FOV turned vertical by the aspect, near 6 and far 12000 — and returns {x, y, depth} in canvas pixels, or null when there is no pixel for the point (behind the eye, inside near, past far, outside the frustum sideways or vertically). It is pure: no DOM, no GL, nothing kept between calls, and Camera comes from renderer.ts as a type-only import so the renderer is not there at runtime. project.test.ts covers a point dead ahead landing exactly at the centre, behind returning null, the x/y sign on all four sides with left/right and up/down mirroring about the middle, the frustum edge at 45°, and the horizontal field of view staying fixed whatever shape the screen is.

drawHud now takes that camera — drawHud(ctx, world, view, camera, width, height, showScoreboard), the camera next to the view it belongs to — and drawPlates draws a name over every player the eye can actually see: alive, projected (so in front and in frame), and traced clear by canSee, the same eye-to-eye geometry the bots shoot by, once per player per frame. Teammates get their name in the side's colour with a health bar and number under it; an enemy gets a name and nothing else. Plates fade from full strength at 400 units to 0.16 alpha by 3000, the font is clamped between 9 and 17 scaled pixels, and they are sorted far-first and drawn under the rest of the HUD so they never cover the clock or the ammo. Nothing is drawn while a held Tab shows the scoreboard, and because the subject is view the plates follow the watched player while spectating.

Worth looking at in the preview: walk up to a teammate and watch the health number track as they take damage, then step behind a crate and confirm the plate is gone — the hud test asserts that case (no wallhack: a player behind a box has no plate, and gets one again in the open), and the spectating test proves the trace is the watched player's eye and not the corpse's. The recording context grew one field, alpha, snapshotted per call, because a fade is a property and not an argument; that is the only change to existing test scaffolding. I measured rather than assumed: nine traces against the map's fifty boxes plus the projections they feed cost 0.04 ms of a 16.7 ms frame. I chose not to touch observe.ts, bots.ts or the RL arena, not to give enemies any health hint, and not to draw an off-screen edge marker — a plate exists only where the player is. bun test is green at 458 tests; README gained a paragraph under the radar's and project in the module list.

🤖 Generated with Claude Code

Closes #91

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs