README
¶
NSGo Game Starter Template
A minimal 2D game template built with NSGo and github.com/nsgo-dev/game.
For a shared project, read the team workflow guide before cloning and run go tool game merge -setup once in each clone.
It demonstrates:
- A fixed-step
game.Loop(60 Hz updates, interpolatedDrawviaalpha, automatic background pause). sprite.Atlas,sprite.Animation,sprite.Sprite, andsprite.Batchdrawn into a full-screencore.Canvas.- A native NSGo HUD (
core.Textandbase.Button) layered above the canvas with safe-area padding and pass-through pointer events. - Headless tests using
nsgotest.Mainandnsgotest.Start.
The game's settings live in game.yaml, its project file. Edit the name and identifier there before shipping it, then write them into nsgo.yaml and check the project:
go run github.com/nsgo-dev/game/cmd/game project sync
go run github.com/nsgo-dev/game/cmd/game project check
Running and Testing
Run with hot reload on your host desktop (macOS, Windows, or Linux):
go tool nsgo dev
Run on other targets:
# Web (opens in browser)
go tool nsgo dev -target web
# iOS simulator or connected device
go tool nsgo dev -target ios_simulator
go tool nsgo dev -target ios
# Android emulator or connected device
go tool nsgo dev -target android
Debug the game's Go code with Delve (dlv on PATH):
go tool nsgo dev -target native -debug
Attach from VS Code with the Attach to game configuration in .vscode/launch.json, replacing 40000 with the port in Delve's API server listening at line, or from GoLand with a Go Remote configuration at the same host and port.
Run headless tests:
go tool nsgo test ./...
Vet and check across platforms:
go tool nsgo check -target macos,windows,linux,android,web
go tool nsgo check -target ios,ios_simulator # on macOS with Xcode
Build release artifacts (output goes to dist/, with -tags=release to strip development-only debug code):
go tool game release
# or invoke nsgo build directly with GOFLAGS=-tags=release:
GOFLAGS=-tags=release go tool nsgo build -target macos_arm64,windows_x64,linux_x64,web
GOFLAGS=-tags=release go tool nsgo build -target ios,android_arm64
Layout
game.yaml— the project file: the game's name, id and version, its window and its export presets per platform, with a virtual resolution, an input map, audio buses and autoloaded scenes and resources to add as the game grows.project.go— embedsgame.yamlasProject.main.go— entry point (nsgo.Run(Root, ...)with the window fromProject).game.go— fixed-stepgame.Loop, procedural two-framesprite.Atlas,core.Canvas, and native HUD overlay.game_test.go,project_test.go— headlessnsgotestand unit tests, and a check thatgame.yamlis canonical,nsgo.yamlagrees with it and the files it autoloads load.nsgo.yaml— NSGo app metadata and dev settings; its name, id, version, appearance and build output and targets followgame.yaml.
Git setup
Each clone enables the object-by-object scene merge driver once (.gitattributes names it, while Git keeps driver config local to .git/config):
go tool game merge -setup