← All Docs

Cart API

Cart API Source Code

A BeepMini cassette is a png image that also contains the game data within it. This allows you to share your game as a single image file. Currently the only way to create a cart is to export it from the BeepMini Editor.

Cart Methods

b8.Cart.load(pngBlobOrUrl) async

Loads a PNG file with a custom trailer (set of game data) and extracts the appended data.

The PNG file should be created using the b8.Cart.save function which appends the required trailer data.

Parameters

  • pngBlobOrUrl (Blob|string): The PNG file as a Blob or a URL.

Returns

  • (Promise<Object>): - A promise that resolves to the extracted data object.

b8.Cart.save(canvas, data [,filename]) async

Saves the current canvas as a PNG file with a custom trailer.

The trailer includes metadata (e.g., game data) appended to the PNG file. This metadata is stored as a JSON object and can be extracted later using the load function.

Parameters

  • canvas (HTMLCanvasElement): The canvas element to save as a PNG file.
  • data (Object|String): The metadata object to append as a trailer. This object will be serialized as JSON.
  • [filename] (string): The name of the file to save. Defaults to “cart.png”. (default: “cart.png”)

Returns

  • (Promise<void>): - A promise that resolves when the file is saved.

More BeepMini Docs

Actors Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

Game Math 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

Textmode

Tilemap Documentation

Utilities Documentation