Bunyip a game engine in Go GitHub

Bunyip

A game engine in Go for real-time and turn-based games: roguelikes, 4X, arcade, and anything that wants 2D sprites and 3D models on the same screen. Vulkan underneath, no cgo, native window and audio layers, and every subsystem a game needs from the first frame to the shipped build.

Get started Build Tetris API reference

Guides

Start

Engine

Graphics

Simulation

Audio

Example programs

Screenshot-capable examples run headless; the window smoke test requires a desktop. Every example has a walkthrough that explains its source section by section.

Packages

Engine

enginePackage engine runs a game's main loop.
inputPackage input reports the state of the keyboard, mouse and gamepads, and names the keys, buttons and axes the platform layers fill that state with.
consolePackage console is the engine's in-game debug console: a drop-down command line over the top of the view, and a window of panels that show what every part of the engine is doing.

Graphics

gfxPackage gfx draws a game's 2D and 3D graphics.
gfx/ktx2Package ktx2 reads and writes KTX2 texture files and encodes and decodes the block-compressed formats they carry.
gfx/shadersPackage shaders holds the gfx package's WGSL sources and committed SPIR-V, and the preludes that game shaders are compiled against.
animPackage anim animates entities.
uiPackage ui is an immediate-mode interface toolkit drawn with gfx.
particlePackage particle simulates 2D particles on the CPU and draws them through the sprite stream: fire, smoke, sparks, rain and confetti from an Emitter of plain fields.
tiledPackage tiled reads maps saved by the Tiled editor and builds drawable levels from them.
gltfPackage gltf loads glTF 2.0 models (.gltf with external or embedded buffers, and .glb) into plain Go slices: positions, normals, UVs, vertex colours, joints and weights, indices, materials with their textures and the KHR extensions the renderer supports (clearcoat, sheen, transmission, volume, IOR, emissive strength, texture transforms, specular, iridescence, anisotropy and converted specular-glossiness), decoded images, morph targets with their default weights, skins, animation clips (node transforms and morph weights) and the flattened node hierarchy with world matrices.
linPackage lin provides the engine's linear algebra: vectors, matrices and quaternions in float32.

Simulation

ecsPackage ecs is the engine's entity component system.
physPackage phys simulates rigid bodies in 2D and 3D on the entity component system.
phys/softPackage soft simulates soft bodies, cloth and fluids as particles on the entity component system.
orbitPackage orbit computes celestial mechanics for space games.
orbit/solPackage sol holds real-world constants for games set in our solar system.

Audio

audioPackage audio mixes sounds in Go and passes float32 stereo frames to the platform's output device.
audio/trackerPackage tracker loads and plays tracker music: ProTracker MOD (4 to 32 channels), ScreamTracker 3 S3M, FastTracker 2 XM and Impulse Tracker IT.

Services

assetPackage asset finds and loads a game's files.
savePackage save stores a game's files in the platform's own data directory: settings, save slots and anything else worth keeping between runs, written as JSON through a synced temporary file and renamed into place to avoid exposing partial JSON.
localePackage locale translates a game's strings.
rngPackage rng provides a small, fast, seedable random number generator (PCG32) for games.
timerPackage timer schedules callbacks on game time, after a delay or on every interval.
tweenPackage tween animates values over time.
gridPackage grid provides the tile-map helpers roguelikes and strategy games need: a generic cell grid, A* and Dijkstra pathfinding, Bresenham lines, shadowcasting field of view and flood fill.
grid/autotilePackage autotile picks tile frames from a terrain grid, so a map of plain terrain ids draws with matching edges, corners and transitions.
networkPackage network moves typed messages between game instances over TCP and UDP.

Tools

cmd/bunyip-bundleCommand bunyip-bundle packages a built game for distribution: a .app bundle on macOS with the Vulkan loader and MoltenVK inside, or a plain folder with the executable and assets elsewhere.
cmd/bunyip-docsCommand bunyip-docs renders the module's documentation as a static website: guides written in Markdown, a walkthrough of every example program, every package's godoc with its examples, a symbol search, and links back to the source on GitHub.
cmd/bunyip-infoCommand bunyip-info reports the graphics stack Bunyip would run on: which Vulkan library loaded, the instance version, and every physical device with its driver and queue families.
cmd/bunyip-packCommand bunyip-pack bundles an asset directory into a pack file that asset.Open can read alongside, or instead of, loose directories.
cmd/bunyip-playCommand bunyip-play plays an audio file through the engine's mixer and the native output device: WAV, Ogg Vorbis, MP3, MOD, S3M, XM or IT.
cmd/bunyip-shaderCommand bunyip-shader compiles WGSL to SPIR-V using the pure-Go compiler.
cmd/bunyip-texCommand bunyip-tex compresses PNG and JPEG images into KTX2 texture files that asset.Texture and gfx.NewCompressedTexture upload straight to the GPU, with the whole mip chain built here rather than while a game runs.
cmd/vkgenCommand vkgen generates the Vulkan binding in internal/vk from the Khronos registry.