Beep8 logo

Cart API

Cart API Source Code

A Beep8 cart (or 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 Beep8 Editor.

Cart Methods

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

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

Actors Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

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