Beep8 logo

Game State

Game State Source Code

Beep8 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.

State Methods

beep8.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: ‘beep8.state’)

beep8.State.init()

Sets default values for missing keys in the state. Does not overwrite existing values.

beep8.State.load()

Loads state from localStorage, replacing State.data.

beep8.State.save()

Saves the current state to localStorage using CBOR and base64.

More Beep8 Docs

Actors Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

Game State

Input Documentation

Inventory API

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

SFX Documentation

Scene Documentation

Text Renderer

Tilemap Documentation

Utilities Documentation