Implementing Volume, Reduced Effects, and Data Reset
Once the enemy and boss content expansion and the credit economy and HANGAR were in place, I turned to an understated but important feature that had been deferred: the OPTION screen. VOID STRIKER combines three groups of settings in a simple vertical menu: separate BGM and SFX volume controls, a SCREEN FX setting that reduces screen shake and flashes from damage and bombs, and WIPE DATA, which completely resets progression data.
A Three-Stage Volume-Mixing Structure
The existing G.Audio module already synthesized SFX and BGM on demand with Web Audio, but it needed to support two independent controls: muting and volume adjustment. The design uses a three-stage structure. A master gain responsible only for mute toggles between zero and its default value, with dedicated SFX and BGM gain nodes connected beneath it. This produces independent behavior: volume settings remain stored while muted, and setting volume to 0% does not affect the mute button state. Moving the volume slider during BGM playback also applies immediately rather than waiting for the next note, giving clear feedback to the control.
Providing an Option to Reduce Effects
VOID STRIKER uses pronounced screen shake and flashes when the player takes damage or activates a bomb, which can burden players sensitive to light or motion. The SCREEN FX setting therefore offers FULL/REDUCED choices. Selecting REDUCED uniformly lowers the strength of screen shake and flashes to about 25%. The implementation avoids changing any call sites for shake or flashes, including damage handling, bomb handling, and boss phase transitions. Instead, the G.Particles module gained a single setReducedFx(reduced) flag. Callers continue to use shake(power)/flash(color, strength) as before, while the particle module decides internally whether to reduce the effect. When adding features, I try to make changes where existing APIs can remain stable, helping keep the overall code easier to follow.
Two-Step Confirmation to Prevent Accidental Erasure
WIPE DATA irreversibly deletes all progression data, including credits, owned skins and themes, and referral-code usage history. Accidental deletion needed to be prevented, but VOID STRIKER's rules prohibit using alert/confirm for confirmation because all UI must remain inside the canvas without depending on external UI. On the first confirm input, the game deletes nothing and only displays a warning that pressing again will erase the data. Actual deletion occurs only if the player confirms again within three seconds. After three seconds, the warning clears automatically and the menu returns to its normal state. Within the constraint of avoiding standard browser dialogs, a single timer variable was enough to create practical protection against accidental input.
Persisting Settings Separately from Game Data
Volume and SCREEN FX settings are stored under the voidstriker_settings localStorage key, separate from in-game economy data such as credits in voidstriker_meta. Economy data and display or audio settings have fundamentally different purposes, so their storage keys are intentionally separate. Each read and write is protected with try/catch, ensuring that a failure to load one does not affect the other. These small separations help keep the game from becoming increasingly fragile as features are added.