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.
Not started. 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 will hold a playable sample game (#8).
- Overview (中文)
- Getting Started (中文)
- Packages (中文): Loop, sprite, sound
- 3D Models from Blender (中文)
- Building and Shipping (中文)
macOS, iOS, Windows, Linux, Android and the web. See Building and Shipping. macOS, iOS, Windows, Linux, Android and the web.
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.2.0+ |
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).