moxzi
Docs / moxzi.game / moxzi.game overview

moxzi.game overviewpreview

How a moxzi.game game is put together, what you write, and what the shared player does for you.

moxzi.game is a framework for games whose logic is written in Motoko. You write the game's rules as actors and describe its scenery, controls and sounds in YAML. A shared player, moxzi-player, runs the actors, draws the scene in 3D, plays sound and handles input, windows, touch and saving.

It's a developer preview. It runs on Apple Silicon Macs and arm64 iPhones. See Platforms.

What you write#

PartFormatContents
game.yamlYAMLThe project: id, title, entry file, simulation rate
src/*.moMotokoThe simulation. One actor is the entry point; it can create others
assets/*.model.yaml, *.glbYAML, glTFShapes and meshes
assets/*.material.yamlYAMLColours and surface properties
assets/controls.ui.yamlYAMLButtons, keys, sliders and on-screen text
assets/*.wavWAVSound effects
assets/*.meta.yamlYAMLOne per asset: its stable id and the name Motoko code uses for it

There's no Rust, C++ or engine code in a game.

How it runs#

The player owns the clock. It calls the entry actor at a fixed rate, set by simulation_hz in game.yaml:

player                                  your entry actor
  │  moxzi_boot(seed)          ───────▶   set up state, create other actors
  │  moxzi_snapshot()          ───────▶   return the whole scene
  │  moxzi_advance(tick)       ───────▶   step the game, return what moved
  │  moxzi_input(command)      ───────▶   a key, button or slider changed
  │  moxzi_lifecycle(suspend)  ───────▶   the app went to the background

The actor holds all game state. The player keeps a copy of the scene only to draw it, and smooths movement between ticks. Because the simulation is ordinary Motoko, it's deterministic: the same seed and the same inputs give the same game, and the whole state can be saved and restored.

Each game actor works like an Internet Computer actor: it processes one message at a time, and a trap rolls back that message. Actors can create other actors and call them with await. Pong's AI opponent is a separate actor.

Tools#

ToolDoes
moxzi-gameChecks, builds and validates projects, generates asset bindings, runs games without a window
moxzi-playerPlays a built game in a window, with saving and restoring
moxziThe Motoko compiler. moxzi-game build uses it

Next steps#

On this pageWhat you writeHow it runsToolsNext steps