Skip to content
nsgo-devPublic

About

A game layer for NSGo apps in Go: a fixed-step loop, input actions, sprites, tilemaps and scenes in 2D first, then 3D

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

game

A game layer for NSGo apps, written in Go, in two stages:

  1. 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.
  2. 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.

Status

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.

Layout

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-step Loop every package shares (guide).
  • game/sprite: atlases, frames, animations, sprites and batches drawn into a Canvas (guide).
  • game/sound: the Mixer, 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).

Docs

Targets

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.

Contributing

See CONTRIBUTING.md for the repository layout, local test and cross-target check commands, coding conventions and pull request guidelines.

Compatibility

game Go NSGo
Unreleased / v0.1.0 1.27+ v0.3.0 or later

Networking

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).

About

A game layer for NSGo apps in Go: a fixed-step loop, input actions, sprites, tilemaps and scenes in 2D first, then 3D

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages