moxzi
Docs / moxzi.game / Projects and commands

Projects and commandspreview

The game.yaml file, project layout, and every moxzi-game and moxzi-player command.

game.yaml#

game.yaml
format_version: 1
project:
  id: com.example.drift
  title: Drift
  version: "0.1.0"
sdk_abi: 1
entry: src/Main.mo
asset_roots: [assets]
simulation_hz: 30
FieldRequiredMeaning
format_versionYes1
project.idYesA reverse-domain id, such as com.example.drift. Saves and iOS app ids use it
project.titleYesWindow and app title
project.versionYesYour game's version
sdk_abiYes1
entryYesThe Motoko file containing the entry actor, relative to the project
asset_rootsYesDirectories containing assets
simulation_hzYesTicks per second. Must match moxzi_describe
motoko_packagesNoLibraries for mo:NAME imports, as NAME: path. Paths must be inside the project
motoko_stack_kibNoStack size for the game's Motoko code, in KiB
capabilitiesNoHost services the game may use. http allows HTTPS outcalls, if the player supports them. Without it, the game has no network access

Imports that are always available: mo:moxzi/… (the game SDK) and mo:game-assets/Assets (your asset bindings, generated at build time).

Using libraries#

There's no mops support in game projects yet. Copy a library's source into the project and name it in motoko_packages. Pong does this with the Motoko base library:

motoko_packages:
  base: vendor/base-0.16.0/src

Calling the Internet Computer#

A game with capabilities: [http] can use the ic-agent library to query and call canisters, for example to submit a score. Vendor it with motoko_packages as above.

Commands#

CommandDoes
moxzi-game check PROJECTReads game.yaml and asset metadata. Doesn't compile
moxzi-game init-assets PROJECTCreates .meta.yaml files for assets that don't have one. Never changes existing files
moxzi-game bindings PROJECTPrints the generated Assets module
moxzi-game build PROJECT OUTCompiles and packages the game into OUT, which must not exist
moxzi-game validate PACKAGEChecks a built package's structure, file hashes and limits
moxzi-game run-headless PACKAGE TICKS native|pulleyRuns the simulation for TICKS ticks without a window and prints a JSON report
moxzi-game inspect-checkpoint SAVEPrints a summary of a save file
moxzi-player PACKAGE native|pulley|aot [SECONDS]Plays a package. With SECONDS, exits after that long

moxzi-game build needs the compiler. Set MOXZI_BIN, MOXZI_COMPILER and MOXZI_LINKER (see Your first game).

Execution backends#

BackendMeaning
nativeCompiles the game's wasm to machine code when it loads. The usual choice on a Mac
pulleyInterprets the wasm. Slower; used where compiling at runtime isn't allowed, such as iOS
aotA build with the game compiled ahead of time into the player. Experimental

Player options#

OptionEffect
--save FILESave the game to FILE periodically and on exit
--restore FILEStart from a save file
--message-fuel NInstruction limit for each call into the game. Default 20,000,000. A call that exceeds it traps

A built package#

FileContents
package.jsonGenerated description of the package. Don't edit it
main.wasmThe compiled game
assets/Copies of your assets
catalog.json, build.jsonAsset catalogue and build provenance
compile.logCompiler output

If a tool says package.json is missing, you've given it a project directory where it expected a built package.

On this pagegame.yamlUsing librariesCalling the Internet ComputerCommandsExecution backendsPlayer optionsA built package