Skip to content

Development source guide ยท workspace 0.1.0

Assets and packed games

Use a stable logical path for each asset, then let the engine's packing interface decide whether its bytes come from development files or an embedded pack. This is how a game avoids accidentally depending on the original working folder after release.

Put files inside the game project

The pack collector includes the project's assets, audio and data directories, skipping dot-prefixed files and directories. Use subfolders to make their purpose clear, and keep private material outside those directories.

For example, an asset placed at first-game/assets/marker.glb has the logical key assets/marker.glb. The key is project-relative and uses forward slashes; it is not an absolute machine path.

Read an asset through the pack interface:

let bytes = pack::read("assets/marker.glb");

The result is optional. Handle a missing asset deliberately rather than assuming every read succeeds. Loading its bytes is only the first step: the game still needs the correct decoder and a rendering or playback path.

Warning. Direct filesystem reads bypass the embedding workflow. A development build can appear to work because the source folder is present, then fail when someone runs the release elsewhere.

Development and release are different

Build Asset behavior What to check
Normal development Reads files through the configured asset root The intended project root is selected and keys match filenames
Release CLI collects and packs files, then builds with the embedding feature The game forwards the feature and uses pack reads rather than unrelated filesystem reads
Web, including development web builds Assets are embedded because the runtime has no native project filesystem Rebuild after changing included files and check browser-specific limits

The scaffold forwards embed to pack/embed. Preserve that feature when changing Cargo.toml. The CLI writes an intermediate pack under target/aigame/assets.pack; it is build output, not a file you hand-edit.

Release packing requests compression level 19 and stores incompressible entries raw. This does not mean every asset becomes small or that a release has no operating-system dependencies. See build and export for that distinction.

The interface also supports mounted overrides, which take precedence over normal embedded or disk lookup. A game using overrides should check that it is seeing the intended resource before diagnosing an old-looking image or table as a packing failure.

Find resources

The website's asset library offers previews and downloads. Copy only files you have the right to use, in the format your game actually expects. Browsing or downloading an asset does not register it with a game.

For a local library, the CLI can open a searchable listing:

AIGameEngine list-assets --library ./engine-source/library

This creates a temporary HTML listing and asks the system browser opener to display it. It is a file/category/size browser, not an import editor or a guarantee that every item can be loaded by every renderer.

The library path defaults to library relative to the command's current directory. Pass --library when working outside the engine root so you do not inspect or create the wrong folder by accident.

Register an asset in a local library

Use a deliberate destination and check that a same-named file will not be replaced:

AIGameEngine library add ./first-game/audio/example.pcm sound-effects --library ./engine-source/library

This example requires an existing raw PCM file; the command does not synthesize or convert it. It checks category, extension and size, then copies the file into the selected library category. It does not automatically copy that file back into every game project.

Current registration limits are:

Category Accepted extensions Maximum file size
sound-effects pcm 256 KiB
music opus, ogg 2048 KiB
voice pcm, opus 512 KiB
interfaces png 64 KiB
3d-objects glb, gltf 256 KiB
voxels glb, vox 256 KiB
3d-characters glb, gltf 512 KiB
2d-sprite-sheets png 128 KiB
2d-characters png 128 KiB
2.5d-characters png, glb 256 KiB
2.5d-objects png, glb 128 KiB

Use lowercase extensions. PCM files must have an even byte count because samples are 16-bit aligned. These are the CLI library-registration checks, not proof that all runtime decoders accept every detail of every file or that these are ideal memory budgets for a game.

Choose the consumer before the format

  • A model's mesh data still needs an actual render integration. The inspected glTF loader is not a complete scene/material/animation importer.
  • An image file is not automatically a button or material; the game must connect its resource representation to the UI or renderer.
  • Raw PCM needs the correct sample interpretation and rate. Renaming a WAV file to .pcm does not remove its container header or convert its samples.
  • A JSON table needs a game-defined schema and consumer. A file under data/ is not automatically a new game mechanic.

See graphics, audio and world content for those connections.

Verify a release without the source folder

Build with release embedding, then test the resulting game from a separate working directory in an authorized test environment. Check actual images, sound and content, not merely that the executable starts. This verification was not performed for the guide's example.

If something is missing only in release, check the collection directories, logical key, embedding feature and any direct filesystem calls. If it is missing in both builds, begin with the filename and consumer instead of changing compression settings.