Getting started
This page gets Molten built on your machine, opens a sample game, and walks you through your first live change.
What you need
| Windows | Linux | |
|---|---|---|
| C++20 compiler | Visual Studio 2022 with the "Desktop development with C++" workload | gcc or clang with C++20 support |
| CMake | 3.25 or newer | 3.25 or newer |
| Git | yes | yes |
| Network | first configure only (CMake downloads pinned dependencies) | same |
| GPU | a Vulkan 1.3 driver | a Vulkan 1.3 driver (Mesa's llvmpipe works for testing) |
| Optional | Python 3.8+ (one editor test), Node + npm (to build the VS Code extension), LLVM with Clang and LLD (to ship a game) | same |
On Linux, SDL3 also needs the X11 and Wayland development packages:
sudo apt install libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev \
libxtst-dev libxfixes-dev libxkbcommon-dev libwayland-dev wayland-protocols libegl-dev \
libdrm-dev libgbm-dev libdecor-0-dev libudev-dev libdbus-1-dev
You do not need the Vulkan SDK. Molten loads Vulkan through volk and builds its own
copy of the TinyCC compiler it uses for live reload. If the Vulkan SDK is installed, Debug
builds turn on Vulkan validation.
Build
From the repository root, one command configures, builds and runs the tests:
cmake --workflow --preset debug
Use --preset release for an optimized build. The release preset leaves out the dev link,
so devtools' Play button does not work with it; use Debug while you develop.
To build without running the tests:
cmake --preset debug
cmake --build --preset debug
The programs land in:
| Platform | Folder |
|---|---|
| Windows | build\debug\bin\Debug\ |
| Linux | build/debug/bin/ |
The ones you will use:
| Program | What it is |
|---|---|
molten-devtools |
The editor |
molten-game |
The engine runtime: runs a game folder with live reload |
molten-dev |
The dev server that connects games and devtools (started for you) |
castc |
The Cast compiler: check, fmt, build, run, test |
cast-lsp |
The language server used by the VS Code extension |
molten-import |
The asset importer (run for you) |
molten |
The shipping tool: molten build --release |
The test windows that CTest opens are hidden and silent, so running the tests will not take over your screen.
Open a sample in the editor
The quickest way in is the dev-run script. It builds the tools and opens a game folder
in devtools:
# Windows (PowerShell or cmd)
dev-run samples\gridline
# Linux
./dev-run.sh samples/gridline
With no argument it opens the welcome screen, where you can start a New project from a
template, open a folder, or pick a recent project. Add -NoBuild (Windows) or --no-build
(Linux) to skip the build step.
Devtools opens in Edit mode: it shows the level as written in its files, and no game is running yet. Press F5 (Play) to launch the game in its own window. Press Shift+F5 to stop it. See Devtools for the whole editor.
Run a game without the editor
# Windows
build\debug\bin\Debug\molten-game --game samples\spin
# Linux
build/debug/bin/molten-game --game samples/spin
| Key | In molten-game |
|---|---|
| Space | Pause or resume simulation in dev-link builds (rendering keeps going) |
| Escape | Quit, unless the game sets escape_quits = false in game.toml |
The samples:
| Folder | What it shows |
|---|---|
samples/spin |
The smallest Cast game: one spinning cube |
samples/farmhouse |
Screens, levels, parts, a Cast Health behavior, a HUD, and some hand-written C |
samples/physics |
Physics Yard: falling boxes, a ramp, a ball launcher (E), contact events |
samples/gridline |
Gridline, a complete small game written only in Cast |
samples/hello, samples/swarm, samples/scene |
Early C-only samples (live C reload, 100k objects, a custom shader) |
Your first live change
Make a copy of the Spin sample so the repository stays clean, then run it:
cp -r samples/spin my-spin # Windows PowerShell: Copy-Item -Recurse samples\spin my-spin
build/debug/bin/molten-game --game my-spin
Leave the window open and try these, saving after each:
-
Change a value in a file. Open
my-spin/objects/spinning_cube.objectand change the color:export default object({ mesh: { mesh: "models/cube.gltf", color: vec4(0.9, 0.3, 0.2, 1) }, spin: { axis: vec3(1, 2, 0) }, });The cube turns red. The console prints a line like
molten: .../objects/spinning_cube.object reloaded (1 objects updated). -
Change code. Open
my-spin/behaviors/spin.castand double the speed:obj.spin.angle = obj.spin.angle + obj.spin.speed * dt * 2;The console prints
molten: module reloaded in ... ms. The cube keeps its current angle and spins faster: the code changed, the state did not. -
Make a mistake. Change line 8 to
const halfAngle: int = obj.spin.angle * 0.5;(afloatcan't go into anintwithoutint(...)). The console printsERROR: molten: build failed, keeping the running module: behaviors/spin.cast:8:47: error: cannot convert float to intand the old code keeps running. Fix the line, save, and it reloads.
That is the whole loop: edit, save, look. Live reload explains what reloads and how state is kept. Next, build a game of your own in the tutorial.
Check a game from the command line
castc check checks a whole game folder (Cast code, concept files, UI and styles) without
running it:
build/debug/bin/castc check my-spin
It prints 2 objects, 1 screen, 1 level when everything is fine, or errors as
file:line:col: error: message. The editor extension shows the same errors as you type
(Editor tooling).