← All Docs

Game State

Game State Source Code

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.

State Methods

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.reset()

Resets the state to an empty object and re-initializes it. This does not clear localStorage.

b8.State.save()

Saves the current state to localStorage using CBOR and base64.

More BeepMini Docs

Actors Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

Game Math Documentation

Game State

Image Processing

Input Documentation

Inventory API

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Path Documentation

Public API

Random Numbers Documentation

SFX Documentation

Scene Documentation

Text Renderer

Textmode

Tilemap Documentation

Utilities Documentation

B8:// Make BeepMini Games