A game layer for NSGo apps, written in Go, in two stages:
- 2D: a fixed-step loop, input actions, sprites, tilemaps, scenes and sound. A game draws into one NSGo view, a
Canvas, a pixel buffer or a shader, and its HUD and menus stay ordinary native NSGo views on top. - 3D: meshes, cameras, lights and glTF models on a GPU view NSGo adds for it (nsgo#1059).
The loop, input actions, sound and scene switching are shared by both stages. It uses only NSGo's public API, so an app that does not import it links none of it.
Early and unreleased. Every package is either stable or experimental: stable packages break their API only in a minor release and only after a deprecation period, experimental ones may change in any minor release. The API stability policy (中文) defines both, describes how deprecations work across releases, and lists each package's status.
The plan is nsgo#1047, and its tasks are this repository's issues. The engine-side primitives it needs (key-up and held keys, display frame times, gamepads, audio everywhere, a batched DrawAtlas, the GPU view) are tracked in NSGo.
A monorepo. The Go module lives in packages/game, and the root go.work uses it, so Go commands also run from the repository root.
game/
├─ go.work
├─ packages/
│ └─ game/ Go module github.com/nsgo-dev/game/packages/game
│ ├─ sprite/
│ └─ sound/
├─ apps/website/ the site at https://game.nsgo.dev
├─ examples/ sample games
└─ docs/
├─ en/ the site's docs in English
└─ zh/ the same pages in Simplified Chinese
Import the packages from github.com/nsgo-dev/game/packages/game:
game: the fixed-stepLoopevery package shares (guide).game/sprite: atlases, frames, animations, sprites and batches drawn into aCanvas(guide).game/sound: theMixer, its effects and music (guide).game/input: input actions (#3).game/tilemap: tilemaps and the camera (#5).game/scene: drawing layers, hit testing and scene switching (#6).
examples/caverun is the playable 2D platformer sample, Cave Run (#8), and examples/lantern3d is the interactive 3D glTF scene sample, Lantern 3D (#205).
- Overview (中文)
- Getting Started (中文)
- Tutorial: Star Catcher (中文), nine chapters from an empty project to a shipped game, with each chapter's code in
examples/tutorial - Packages (中文): Loop, sprite, sound
- API Stability (中文)
- Agent Skill (中文) — installable via
bunx skills add nsgo-dev/game - 3D Models from Blender (中文)
- Building and Shipping (中文)
macOS, iOS, Windows, Linux, Android and the web. See Building and Shipping.
Consoles (Nintendo Switch, PlayStation and Xbox) are out of scope: their SDKs are under NDA and need C toolchains, and NSGo and this repository are Go only, with no hand-written C.
See CONTRIBUTING.md for the repository layout, local test and cross-target check commands, coding conventions and pull request guidelines.
game |
Go | NSGo |
|---|---|---|
Unreleased / v0.1.0 |
1.27+ | v0.3.0 or later |
game/net provides cross-target WebSocket, UDP and loopback transports with snapshot replication and deterministic lockstep/rollback helpers over game.Loop (#41). Matchmaking, hosted backends and account services stay out of the game layer: games use Go's standard library or any networking package directly. Local multiplayer on one device belongs in game/input (#3, #128).