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.
Rendering
Sprites, tilemaps and scalable text on top of a physically based 3D renderer with cascaded shadows, ambient occlusion, bloom and skeletal animation. No Vulkan knowledge required.
Interface
An immediate-mode toolkit rebuilt every frame: panels, buttons, sliders, drop-downs, scroll areas, text fields with IME support, eight colour themes and texture skins.
Audio
A mixer with streamed music, positional voices, reverb and filters, priorities and fades, plus a tracker player for MOD, S3M, XM and IT.
Game services
An archetype-based entity component system with systems, resources and events, assets with packs and hot reload, saves and settings, seeded random numbers, timers and tweens, grids with pathfinding, and TCP and UDP messaging.
Guides
Start
- Introduction — what Bunyip is, how it is put together, and what to read next
- Why Go? — why Go is a practical foundation for a game engine, and the tradeoffs to understand
- Getting started — install the Vulkan driver, open a window, learn the loop and the window controls
- API design — ownership, cleanup, scoped work, useful defaults and typed operations
- Building Tetris — a complete game on the entity component system, step by step
Engine
- The window — how the window is opened, sized and controlled, what is fixed at start and what changes at run time
- Input — keys, mouse, gamepads, action maps and rebinding
- Entities and systems — the entity component system, how it stores data, and how to structure a game around it
- Game services — assets, saves, translation, random numbers, timers, sequences, tweens, grids and networking
- The debug console — the in-game command line, its commands and variables, and the panels that show what the engine is doing
Graphics
- 2D graphics — sprites, bounds, reusable geometry, atlases, cameras, tilemaps, text, vector paths, particles, lights and render textures
- 3D graphics — cameras, meshes and models, materials, lights and shadows, sky and fog, culling and LOD, post-processing and render textures for a 3D game
- Shaders — WGSL authoring, native Go compilation, engine hooks, uniforms and texture bindings
- Animation — keyframe clips for 2D sprites and 3D transforms, flipbooks, skeletons with crossfades, events, root motion, layers, blend spaces, IK and morph targets
- The interface — immediate-mode widgets, layout, keyboard and gamepad navigation, drag and drop, themes and skins
Simulation
- Physics — rigid bodies in 2D and 3D: shapes, collisions, queries, joints, ragdolls and character controllers, and the cloth, soft bodies and fluids beside them
- Orbits and space — celestial mechanics for any star system: Kepler orbits, N-body gravity, ships under thrust
Audio
- Audio — sounds, music, positional voices, reverb, occlusion, effects and tracker music
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.
- Animation — keyframe clips on 2D sprites and 3D transforms, a flipbook, crossfades driven by Finished events, and three skeletal arms showing an animation event, two-bone IK and a blend space
- Assets — a directory of images loaded on worker goroutines behind a progress bar, reloaded when they change on disk, packed into a pack file, with settings that persist between runs
- Audio — positional voices orbiting a listener with Doppler, occlusion and a binaural head model, reverb and low-pass on sliders, fades, pitch, voice stealing, a synthesised music stream and microphone capture
- Autotile — terrain that picks its own tiles: a 47-tile blob set expanded from a six-tile template, a 16-tile edge set for walls, a corner Wang set whose shorelines curve, and a 64-tile hexagonal edge set in the strip below
- Clear — the renderer's smoke test: a window cleared to a cycling colour, with one frame written to a PNG
- Gallery — every widget in the interface package, the built-in themes, a texture skin, menus, modals, drag and drop, tables, scalable text and a live particle editor
- Inputs — everything the input package reports, drawn live: keys, mouse, wheel, capture, fullscreen, typed text with IME composition, and four gamepads
- Lighting — skinned meshes bent by joint matrices under cascaded shadows, two lamps with cube shadow maps over a field of 160 clustered point lights, a procedural sky that thins to orbit, image-based lighting, and every post-processing setting on a slider including temporal anti-aliasing, depth of field, motion blur, god rays and the lens effects
- Materials — every material feature on a row of spheres and a few props: clearcoat, sheen, subsurface, glass, iridescence, anisotropy, a specular tint, fur, alpha cutout, vertex colours, a scrolling texture, a decal, an outline, an x-ray tint and a stencil mask
- Network — a chat room over TCP with pointer positions over UDP, turn-based and asleep until a message arrives, with reliable UDP and its round trip and loss
- Particles — a campfire of fire and smoke, instanced rain, sparks on click and confetti on Space, with a panel that retunes the fire while it burns
- Pathfinding — A*, Dijkstra maps, field of view, flood fill and lines on a grid painted with the mouse, saved and loaded through the save package
- Physics lab — capsules, hulls and boxes on a mesh terrain, a hinge chain, a motorised paddle wheel, a ragdoll and a character controller on stairs
- Physics 2D — balls, boxes and triangles falling into a pit with a ramp, a kinematic paddle, a car on sprung wheel joints, a trigger zone and a raycast
- Physics 3D — five hundred textured cubes of wood, plastic, metal, gold, car paint, velvet, glass and glowing material falling into a concrete pen
- Probes — a reflection probe baked inside a glowing room, a grid of light probes that colours the matte balls by the wall they stand near, and screen-space reflections on a polished floor, each on a checkbox
- Roguelike — a turn-based dungeon crawl with generated rooms, line of sight, chasing goblins and a message log, running in the engine's turn-based mode
- Shaders — game-written WGSL compiled to SPIR-V in Go, as 2D sprite shaders and mesh surface and vertex hooks, with uniforms driven by sliders
- Soft bodies — a cloth flag flapping on a pole, a jelly cube that drops and can be kicked beside a rigid crate, and a tank of 2D fluid breaking around a post
- Solar system — the entity component system driving a 3D scene loaded from a scene document, with a prefab, a parent-child hierarchy, an instanced asteroid belt, picking and a render-texture minimap
- Space — a ship under gravity in a fictional star system on exact Kepler orbits, with a floating origin, orbit prediction and a slider panel
- Sprites — a few hundred textured sprites bouncing over a grid, a lit brick floor where a circling lamp throws shadows from three crates, and a key that runs the 2D frame through the post pass
- Terrain — a chunked terrain with levels of detail and a splat map, impostors, billboards, point and spot lights, fog, world text and live edits
- Tetris — a complete game on the entity component system, with components, resources, events, systems, timers, tweens, sound and a panel
- Shaped text — HarfBuzz shaping, bidirectional and vertical text, fallback fonts, wrapping, hyphenation in the text's own language, rich text, colour glyphs and distance-field text
- Tiled maps — a map from the Tiled editor, embedded as a .tmj, built into tilemaps with animated and flipped tiles and outlined objects
- Tiles — a sprite sheet, a culled tilemap, a following 2D camera, a walk cycle, layers, timers, tweens and a nine-slice HUD
- Vector paths — filled and stroked paths, fill rules, curves, caps and joins, textured fills, blend modes and the transform stack
- Model viewer — an orbit camera over a generated 3D scene, or a glTF model loaded from disk, with lights, shadows and ambient occlusion
- Window — the platform layer's smoke test, opening a native window and presenting cleared frames without the engine
Packages
Engine
| engine | Package engine runs a game's main loop. |
| input | Package input reports the state of the keyboard, mouse and gamepads, and names the keys, buttons and axes the platform layers fill that state with. |
| console | Package 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
| gfx | Package gfx draws a game's 2D and 3D graphics. |
| gfx/ktx2 | Package ktx2 reads and writes KTX2 texture files and encodes and decodes the block-compressed formats they carry. |
| gfx/shaders | Package shaders holds the gfx package's WGSL sources and committed SPIR-V, and the preludes that game shaders are compiled against. |
| anim | Package anim animates entities. |
| ui | Package ui is an immediate-mode interface toolkit drawn with gfx. |
| particle | Package 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. |
| tiled | Package tiled reads maps saved by the Tiled editor and builds drawable levels from them. |
| gltf | Package 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. |
| lin | Package lin provides the engine's linear algebra: vectors, matrices and quaternions in float32. |
Simulation
| ecs | Package ecs is the engine's entity component system. |
| phys | Package phys simulates rigid bodies in 2D and 3D on the entity component system. |
| phys/soft | Package soft simulates soft bodies, cloth and fluids as particles on the entity component system. |
| orbit | Package orbit computes celestial mechanics for space games. |
| orbit/sol | Package sol holds real-world constants for games set in our solar system. |
Audio
| audio | Package audio mixes sounds in Go and passes float32 stereo frames to the platform's output device. |
| audio/tracker | Package tracker loads and plays tracker music: ProTracker MOD (4 to 32 channels), ScreamTracker 3 S3M, FastTracker 2 XM and Impulse Tracker IT. |
Services
| asset | Package asset finds and loads a game's files. |
| save | Package 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. |
| locale | Package locale translates a game's strings. |
| rng | Package rng provides a small, fast, seedable random number generator (PCG32) for games. |
| timer | Package timer schedules callbacks on game time, after a delay or on every interval. |
| tween | Package tween animates values over time. |
| grid | Package 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/autotile | Package autotile picks tile frames from a terrain grid, so a map of plain terrain ids draws with matching edges, corners and transitions. |
| network | Package network moves typed messages between game instances over TCP and UDP. |
Tools
| cmd/bunyip-bundle | Command 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-docs | Command 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-info | Command 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-pack | Command bunyip-pack bundles an asset directory into a pack file that asset.Open can read alongside, or instead of, loose directories. |
| cmd/bunyip-play | Command 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-shader | Command bunyip-shader compiles WGSL to SPIR-V using the pure-Go compiler. |
| cmd/bunyip-tex | Command 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/vkgen | Command vkgen generates the Vulkan binding in internal/vk from the Khronos registry. |