Getting Started
Prerequisites
- Rust (stable toolchain, 1.85+)
- wasm-pack for building WASM targets
- Node.js 18+ and pnpm for website/docs development
- A modern browser with hardware WebGPU support for the primary renderer, or WebGL2 support for fallback rendering
Install Tools
# Rust (if not installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# WASM target
rustup target add wasm32-unknown-unknown
# wasm-pack
cargo install wasm-pack
# pnpm (if not installed)
npm install -g pnpm
# Or use the Makefile
make install-tools
Clone and Build
cd siliconghetto
# Build all crates
cargo build
# Run tests
cargo test
# Check lints
cargo clippy -- -D warnings
Run a Demo
Build a demo for the browser and serve it with cross-origin isolation headers:
# Build the sprite-lab demo
wasm-pack build demos/sprite-lab --target web --out-dir www/pkg
# Serve with required headers
cd demos/sprite-lab/www
python3 -c "
from http.server import HTTPServer, SimpleHTTPRequestHandler
class H(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
super().end_headers()
HTTPServer(('localhost', 8080), H).serve_forever()
"
Open http://localhost:8080 in your browser. You should see 500 bouncing sprites. Press Space to add more.
Start From The Platform API
New browser games should use sg.createGame() as the composition entry point:
import sg from './sg.js';
const game = await sg.createGame({
runtime: {
tickRate: 60,
deterministic: true,
saveProfile: 'sg.save.v2',
},
world: {
canvas: 'game-canvas',
topology: 'chunked-grid-3d',
streaming: 'player-centric',
seed: 42,
},
packs: [],
capabilities: ['procedural_world'],
});
sg.run({
update() {
sg.fpsUpdate();
},
draw() {
sg.clear(0.5, 0.7, 1.0);
},
});
console.log(game.composition.bootMode);
First-party survival is available as a template by composing the sg.survival pack:
await sg.createGame({
world: { canvas: 'game-canvas', seed: 42 },
packs: [`${sg.registeredPacks()[0].id}@${sg.registeredPacks()[0].version}`],
});
Pack references are validated during composition. Use sg.registeredPacks() to inspect first-party IDs, versions, and capabilities. Registered first-party packs can omit the version, while unknown pack IDs and unsupported versions fail fast.
Build All Demos
make build-wasm
This builds all four demos (sprite-lab, topdown-prototype, scene3d, stress-lab) as WASM packages.
Project Structure
siliconghetto/
├── crates/ # Engine crates (the core library)
├── demos/ # Browser-playable demo games
├── apps/ # Website and docs (Astro)
├── platform/ # Future platform scaffolding
├── infra/ # Deployment infrastructure
├── docs-content/ # Documentation source (Markdown)
└── Cargo.toml # Workspace root
Available Demos
| Demo | Description | Controls |
|---|---|---|
| sprite-lab | 500+ bouncing sprites with collision | Space: add sprites |
| topdown-prototype | Top-down movement with enemies | WASD: move |
| scene3d | Lit 3D cube with orbit camera | (automatic rotation) |
| stress-lab | Auto-scaling performance benchmark | Space: add entities |
Development Workflow
# Format code
cargo fmt
# Check for errors
cargo check
# Run clippy lints
cargo clippy -- -D warnings
# Run tests
cargo test
# Full CI check
make ci
CLI Tool
The sg CLI helps with development tasks:
# Show help
cargo run --bin sg -- --help
# Validate a game manifest
cargo run --bin sg -- validate demos/sprite-lab/sg-game.toml
Next Steps
- Read the Architecture Overview to understand the runtime platform design
- See the Contributing Guide to learn how to contribute
- Check Browser Platform for supported browser versions
- Explore the ADRs for the reasoning behind key decisions