Alpha -- GoudEngine is under active development. APIs change frequently. Report issues
This guide covers installing the Go SDK, opening a window, drawing a sprite, and handling input.
See also: C# guide -- Python guide -- TypeScript guide -- Rust guide -- Swift guide -- Kotlin guide
- Go 1.21 or later
- A C compiler (GCC or Clang) -- required for cgo
- Rust toolchain -- needed to build the native engine library
The Go SDK wraps the native Rust engine through its C FFI. Build the engine first:
git clone https://github.com/aram-devdocs/GoudEngine.git
cd GoudEngine
cargo build --releaseThis produces target/release/libgoud_engine.dylib (macOS), libgoud_engine.so (Linux), or goud_engine.dll (Windows).
The Go SDK uses cgo to call into the native library. Add the module to your project:
go get github.com/aram-devdocs/GoudEngine/sdks/goFor local development from the repository, the SDK is at sdks/go/. Set CGO flags to find the native library:
export CGO_CFLAGS="-I$(pwd)/sdks/go/include"
export CGO_LDFLAGS="-L$(pwd)/target/release"Create main.go:
package main
import "github.com/aram-devdocs/GoudEngine/sdks/go/goud"
func main() {
game := goud.NewGame(800, 600, "My First Game")
defer game.Destroy()
for !game.ShouldClose() {
game.BeginFrame(0.2, 0.2, 0.2, 1.0)
if game.IsKeyJustPressed(goud.KeyEscape) {
game.Close()
}
game.EndFrame()
}
}Run it:
CGO_ENABLED=1 go run main.goA window opens at 800x600 and closes when you press Escape.
BeginFrame clears the screen to the given RGBA color and prepares the frame. EndFrame swaps buffers and polls events. Everything you draw goes between those two calls.
Load textures once before the game loop, then draw each frame.
package main
import "github.com/aram-devdocs/GoudEngine/sdks/go/goud"
func main() {
game := goud.NewGame(800, 600, "Sprite Demo")
defer game.Destroy()
tex := game.LoadTexture("assets/player.png")
for !game.ShouldClose() {
game.BeginFrame(0.1, 0.1, 0.1, 1.0)
game.DrawSprite(tex, 400, 300, 64, 64, 0, goud.ColorWhite())
if game.IsKeyJustPressed(goud.KeyEscape) {
game.Close()
}
game.EndFrame()
}
}DrawSprite takes the center position of the sprite, width, height, rotation in radians, and a color tint.
Put your image files in an assets/ folder next to your project. The path is relative to the working directory.
Two modes are available: just pressed this frame, or held continuously.
// One-shot: true only on the frame the key goes down
if game.IsKeyJustPressed(goud.KeySpace) {
// jump
}
// Held: true every frame the key is down
if game.IsKeyPressed(goud.KeyW) {
y -= speed * game.DeltaTime()
}
if game.IsKeyPressed(goud.KeyS) {
y += speed * game.DeltaTime()
}DeltaTime() is the elapsed seconds since the last frame. Use it to make movement frame-rate independent.
Common key constants: goud.KeyEscape, goud.KeySpace, goud.KeyEnter, goud.KeyW, goud.KeyA, goud.KeyS, goud.KeyD, goud.KeyLeft, goud.KeyRight, goud.KeyUp, goud.KeyDown.
if game.IsMouseButtonPressed(goud.MouseButtonLeft) {
// click action
}
mouseX := game.MouseX()
mouseY := game.MouseY()Mouse button constants: goud.MouseButtonLeft, goud.MouseButtonRight, goud.MouseButtonMiddle.
| Import | Description |
|---|---|
goud.NewGame |
Create a windowed game instance |
goud.Color |
RGBA color (goud.ColorWhite(), goud.ColorRGB(r, g, b)) |
goud.Vec2 |
2D vector with arithmetic methods |
goud.Vec3 |
3D vector |
goud.Rect |
Rectangle (x, y, width, height) |
goud.Transform2D |
2D position, rotation, scale |
goud.EntityID |
ECS entity handle |
The repository includes a complete Flappy Bird clone in Go:
git clone https://github.com/aram-devdocs/GoudEngine.git
cd GoudEngine
cargo build --release
./dev.sh --sdk go --game flappy_birddev.sh builds the native library and launches the example. Source is in examples/go/flappy_bird/.
All files in sdks/go/goud/ and sdks/go/internal/ffi/helpers.go are auto-generated. Do not hand-edit them. Regenerate with:
python3 codegen/gen_go_sdk.py # Wrapper package
python3 codegen/gen_go.py # Internal cgo bindings- Go SDK README -- full architecture and API overview
- Go examples source -- complete game source code
- Build Your First Game -- end-to-end minimal game walkthrough
- Example Showcase -- current cross-language parity matrix
- SDK-first architecture -- how the engine layers fit together
- Development guide -- building from source, version management, git hooks
- Other getting started guides: C# -- Python -- TypeScript -- Rust -- Swift -- Kotlin -- Lua