Game State
BeepMini includes a built-in game state system that automatically saves player progress and settings to the browser’s localStorage. This makes game data easy to manage, and allows players to close and continue their games without any extra setup.
You can use the state system to store whatever you like. Usage is simple, just add data to the b8.data
object, and it will be saved automatically.
b8.State.clear([key])
Resets the state to its initial values. This is useful for starting a new game or resetting the application.
Parameters
- [key] (string): Optional localStorage key. (default: ‘b8.state’)
b8.State.init()
Sets default values for missing keys in the state. Does not overwrite existing values.
b8.State.load()
Loads state from localStorage, replacing State.data.
b8.State.save()
Saves the current state to localStorage using CBOR and base64.