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

forked from trevato/cs

A player can turn the sound off in either game, and the page remembers #69

open not picked up yet opened this
opened this

The engine's sound device has had a muted flag since #4 and src/client/audio.ts passes it through, and neither game exposes it: the shooter's menu offers Match, Name, Sensitivity and Side, and a person who wants to play in a quiet room has to mute the browser tab. Give both games the switch, and remember it.

Done looks like

  • [ ] The shooter's menu gains a sound control beside Sensitivity — a checkbox or a two-state button, labelled, reachable by keyboard, and at least 44px on a phone — and the pause overlay can reach it too without ending the round.
  • [ ] The range gains the same control in the same place on its page, wired to its own device from #52, so the two games agree about what the switch looks like and where it lives.
  • [ ] Muting is silence, not a volume of zero: nothing is scheduled while muted, so a muted page pays nothing per shot — a test asserts the device is asked for no sound while muted and for sound again after unmuting.
  • [ ] The choice survives a reload, per game, under the keys the games already use for their small settings (cs. and the range's own prefix), and a stored value that is not a boolean is ignored rather than trusted.
  • [ ] Muted is the default nowhere: a first visit sounds as it does today, and the control shows the state it is actually in on load rather than assuming.
  • [ ] Tests would fail without this: the shooter's frame test toggles the control and sees the device's muted follow, a reload with the stored value set starts muted and with junk stored starts unmuted, and the range's boot test does the same with its own control. No test needs a browser.
  • [ ] No new endpoint, no cookie, no dependency: this is localStorage and a flag on a device that already has it. The security floor and the pages' escaping are untouched, and both bundles are rebuilt and committed with their ceilings held.
  • [ ] Both pages say what the control does in a few words, and README.md mentions that sound can be turned off in both games.

Files I expect to change

src/pages/game.ts, src/pages/range.ts, src/client/main.ts, src/range/main.ts, src/client/main.test.ts, src/range/boot.test.ts, README.md, both bundles in static/.

Priors and risks

This waits for #52, which gives the range a device to mute; doing the shooter alone would set the convention in one game and leave the other to guess. A browser will not open an AudioContext before a gesture, so the control must work before any sound has been made — toggle a flag, never construct a device to mute it. Keep it out of the frame: read the control on change, not every tick. And do not grow a settings panel; this is one switch per game, in the place the other settings already live.

Suggested: Vesper — the pages and the audio recipes are theirs, and this is a comfort a player notices immediately.

commented

Since #208 this stopped being a comfort and became the thing a first visit needs: the round now makes gunfire, footsteps, a plant, a defuse and a bomb that beeps faster as it burns, and neither game offers any way to stop it short of muting the browser tab. device.muted exists and nothing in either entry ever sets it. The chain #73 → this is now the most customer-visible ready work on the map; #73 is small and ready.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs