Bash.tv → GitHub → itch.io

Graphics, audio, control and accessibility preferences for browser games, with one tested settings store. A schema with defaults, ranges, steps and labels; every saved value checked so a broken save can't crash the game; version upgrades; graphics presets and a first-run quality guess from the device; reduced motion from the system setting; listeners that apply changes instantly (and on startup...

Download skill (.zip) Files on GitHub

Game settings system

Settings every web game should have

Group Settings
Audio Master, Music, Sound effects (sliders), mute when in background
Graphics Quality preset, resolution scale, particles, frame rate limit, show FPS
Controls Remap (game-control-customization), sensitivity, invert Y, vibration, touch button size
Accessibility Screen shake amount, reduce motion, flashing effects, text size, color filter, subtitles, game speed
General Language (game-localization), “Show tips again”, reset progress (with confirm)

Skip what doesn’t apply (no invert Y in a puzzle game), but audio and accessibility always apply.

assets/settings.js

import { createSettings, SETTINGS, PRESETS, detectPreset } from "./settings.js";
const settings = createSettings({ key: "my-game:settings", version: 1, schema: SETTINGS });
if (!localStorage.getItem("my-game:settings")) settings.applyPreset("graphics", detectPreset());   // first run guess
settings.on("musicVolume", (v) => audio.setMusicVolume(v));         // runs now with the saved value, then on every change
settings.on("reducedMotion", (v) => (transitions.reducedMotion = v));
settings.on("colorblind", (v) => applyColorFilter(canvas, v));      // game-accessibility-audit
menu items: settings.menuItems("audio", { labels: (s, key) => t("settings." + key) })
settings.reset("graphics"); settings.all(); settings.flush()        // flush before the page closes if you need it

Rules

Tested

Node tests: defaults, the system reduced-motion default, listeners firing on subscribe and change, clamping and steps, refusing bad values and unknown keys, presets, reload keeping values and fixing bad ones, a broken save falling back to defaults, migration, reset by group, generated menu items, and the device preset guess. Used in the UI kit demo (saved across reloads).

Pitfalls

Settings that need a restart, volume sliders that only apply to new sounds, no master volume, accessibility options hidden in a submenu nobody finds, and crashing on an old saved value.