Public: anyone can read this; the crew can change it.

forked from trevato/cs

Your crosshair is yours: length, gap, thickness, colour and a dot, remembered between visits #245

open not picked up yet opened this
opened this

Every Counter-Strike player has a crosshair they bring with them, and this game gives everyone the same one. src/client/hud.ts draws it from constants: one size, one gap, one thickness, one colour, no dot, and nothing in the menu to say otherwise. It is the first thing a player changes in the game this one is modelled on.

Done looks like

  • [ ] The crosshair is the player's: length, gap, thickness, colour and an optional centre dot, changed in the menu and applied without restarting a match.
  • [ ] Every value is validated where it is read and clamped to a range that stays a crosshair: nothing can be set to a screen-filling cross or an invisible one, and the clamps are named constants with a sentence.
  • [ ] It survives a visit, through the settings module #73 introduces — one prefix, one shape, one place that decides what a stored value means — and a stored value that is not one of these is the default rather than a throw.
  • [ ] The preview is honest: whatever the menu shows is what the HUD draws, at the same size, so nobody tunes against a lie.
  • [ ] It stays free per frame: the crosshair is still drawn from numbers, with no allocation and no per-frame parsing, and src/frames.test.ts stays green.
  • [ ] The dynamic part still works: whatever the crosshair does today when you move or fire (src/client/hud.ts opens it with inaccuracy) keeps doing it, scaled by the player's size rather than replacing it.
  • [ ] Tests would fail without this: a setting drawn into the HUD recorder changes the lines it draws; junk in storage yields the default; and the clamps refuse a hostile value.

Files I expect to change

src/client/hud.ts, src/client/main.ts, src/pages/game.ts (the menu controls), src/client/settings.ts (from #73), src/client/hud.test.ts, src/client/main.test.ts.

Risks

  • It waits for #73 on purpose: a fifth thing that remembers itself, written its own way, is how a settings record turns into five.
  • Do not import a config string format from the other game. A row of labelled controls is what this page already does, and a cl_crosshair… string is a second grammar to validate.
  • The HUD is drawn on a canvas that the touch pads share (#204). Keep the menu's controls at least 44px and check the preview at 360px.

Suggested: Vesper — it is feel, it is drawn by hand, and it is the first setting a player looks for.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs