Feature Overview

A complete reference of every feature GoSprite64 provides, organized by section.

Core (gosprite64)

FeatureDescriptionDocs
Game interfaceInit(), Update(), Draw() lifecycle for your gameGame Loop
Run(g Game)Starts the 60 FPS game loop with fixed timestepGame Loop
288x216 canvasFixed logical resolution for all drawing APIsFixed Canvas
16-color paletteBuilt-in named colors: Black, White, Red, etc.Colors

Drawing Functions

FeatureDescriptionDocs
ClearScreen()Fills the screen with blackDrawing Primitives
ClearScreenWith(c)Fills the screen with any colorDrawing Primitives
FillRect(x1,y1,x2,y2,c)Draws a filled rectangleDrawing Primitives
DrawRect(x1,y1,x2,y2,c)Draws a rectangle outlineDrawing Primitives
DrawLine(x1,y1,x2,y2,c)Draws a 1px line (Bresenham for diagonals)Drawing Primitives
DrawText(str,x,y,c)Draws text using the built-in 8x8 fontDrawing Primitives
DrawImage(src,x,y)Draws a Go image.Image at logical coordinatesDrawing Primitives
DrawWorldImage(src,x,y,cam)Draws an image offset by camera positionDrawing Primitives

Sprites

FeatureDescriptionDocs
LoadSpriteSheet(path)Loads a .sheet file from the cartridge filesystemSprite Sheets
SpriteSheet.FrameCount()Returns the number of frames in the sheetSprite Sheets
SpriteSheet.FrameWidth()Returns the pixel width of a single frameSprite Sheets
SpriteSheet.FrameHeight()Returns the pixel height of a single frameSprite Sheets
DrawSprite(sheet,frame,x,y)Draws a sprite frame at logical coordinatesSprites
DrawSpriteWithOptions(...)Draws with flip, scale, rotation, blend, and alphaSprites
DrawWorldSprite(...)Draws a sprite offset by camera positionSprites
DrawWorldSpriteWithOptions(...)World-space sprite with full draw optionsSprites
DrawSpriteOptionsStruct: FlipH, FlipV, ScaleX/Y, Rotation, Origin, Blend, AlphaSprites
BlendNone, BlendMasked, BlendAlphaBlend mode constants for sprite drawingSprites

Animation

FeatureDescriptionDocs
AnimationSetCollection of named animation clips loaded from .anim filesAnimation Player
AnimationClipA single animation: name, FPS, and frame indicesAnimation Player
NewAnimationPlayer()Creates a player that drives sprite frame changesAnimation Player
AnimationPlayer.Play(clip)Starts playing a clip from the beginningAnimation Player
AnimationPlayer.Advance(ticks)Advances the animation by N ticks (call each frame with 1)Animation Player
AnimationPlayer.Frame()Returns the current sprite sheet frame indexAnimation Player
AnimationPlayer.SetLoop(bool)Enables or disables loopingAnimation Player
AnimationPlayer.Pause/Resume/Stop/RestartPlayback controlAnimation Player
AnimationPlayer.Playing() / Done()Status queriesAnimation Player

Custom Fonts

FeatureDescriptionDocs
NewFont(sheet, glyphs, lineHeight)Creates a font from a sprite sheet and glyph mapCustom Fonts
Font.DrawTextEx(text, x, y, align)Draws text with left/center/right alignmentText Alignment
Font.MeasureText(text)Returns pixel width and height of rendered textCustom Fonts
Font.WrapText(text, maxWidth)Inserts newlines to fit text within a pixel widthText Alignment
FormatScore(score, width)Formats an integer with leading zerosCustom Fonts
AlignLeft, AlignCenter, AlignRightText alignment constantsText Alignment

Parallax Scrolling

FeatureDescriptionDocs
NewParallaxConfig(speeds...)Configures multi-layer parallax with speed factorsParallax Scrolling
ParallaxConfig.LayerOffset(layer, camX, camY)Returns the scroll offset for a given layer and cameraParallax Scrolling
ParallaxLayerDefines SpeedX and SpeedY multipliers (0.0 = static, 1.0 = full speed)Parallax Scrolling

Screen Transitions

FeatureDescriptionDocs
StartTransition(style, frames)Begins a fade transition over N framesTransitions
FadeToBlack, FadeFromBlackTransition style constantsTransitions
Transition.Advance()Steps the transition forward one frameTransitions
Transition.Draw()Renders the transition overlayTransitions
Transition.Done() / Active() / Stop()Status and controlTransitions

Draw Regions

FeatureDescriptionDocs
SetDrawRegion(x, y, w, h)Restricts drawing to a sub-rectangle (for split-screen)Draw Regions
ResetDrawRegion()Pops the most recent draw regionDraw Regions
DrawRegion.Clip(...)Offsets and clips coordinates to region boundsDraw Regions
DrawRegion.ContainsPoint(x, y)Hit-tests a local coordinate against the regionDraw Regions

Input

FeatureDescriptionDocs
IsButtonDown(button)Returns true while a button is held (port 0)D-Pad and Buttons
IsButtonJustPressed(button)Returns true on the frame a button is first pressed (port 0)D-Pad and Buttons
StickPosition(deadzone)Returns analog stick X/Y in [-1.0, 1.0] (port 0)Analog Stick
PlayerButtonDown(port, button)Per-port button check for multiplayerMulti-Controller
PlayerButtonJustPressed(port, button)Per-port just-pressed checkMulti-Controller
PlayerStickPosition(port, deadzone)Per-port analog stickMulti-Controller
IsControllerConnected(port)Checks if a controller is plugged inMulti-Controller
ConnectedControllers()Returns the number of connected controllersMulti-Controller
SetRumble(port, enabled)Turns the Rumble Pak on or offRumble
Button constantsButtonA, ButtonB, ButtonZ, ButtonStart, ButtonDPadUp/Down/Left/Right, ButtonL, ButtonR, ButtonCUp/Down/Left/RightD-Pad and Buttons

Input Recording and Replay

FeatureDescriptionDocs
NewInputRecorder(playerCount)Creates a recorder that captures per-frame controller stateInput Replay
InputRecorder.CaptureFrame(player, input)Records one frame of inputInput Replay
InputRecorder.Finish()Finalizes recording into ReplayDataInput Replay
NewInputPlayer(data)Creates a player that replays recorded inputInput Replay
InputPlayer.NextFrame(player)Returns the next frame of recorded inputInput Replay
InputPlayer.Done() / Reset()Playback status and restartInput Replay

Audio

FeatureDescriptionDocs
RegisterAudioBundle(bundle)Registers VADPCM audio assets before the game loop startsSFX and Music
PlaySoundEffect(id)Triggers a one-shot sound effectSFX and Music
PlayMusic(id)Starts background music playbackSFX and Music
StopMusic()Stops the current music trackSFX and Music
SetSoundEffectVolume(v)Sets SFX volume (0.0 to 1.0)SFX and Music
SetMusicVolume(v)Sets music volume (0.0 to 1.0)SFX and Music
sequence.NewPlayer()Creates a MIDI-like sequence playerSequence Player
sequence.Player.Play/Stop/Pause/ResumeSequence playback controlSequence Player
sequence.Player.SetTempo(bpm)Sets playback tempoSequence Player
sequence.Player.SetLoop(start, count)Configures loop pointsSequence Player

Tile Scene Pipeline

FeatureDescriptionDocs
OpenBundle(path)Opens a .bundle file containing sheets, maps, and animationsBundles and Loading
LoadScene(bundle)Loads all assets from a bundle into a renderable scenePipeline Overview
Scene.Draw(cam)Renders visible tiles to the screen through the cameraCamera and Scrolling
Scene.Map()Returns the scene's Map for tile queriesTile Sheets and Maps
Map.Width() / Height()Map dimensions in tilesTile Sheets and Maps
Map.TileWidth() / TileHeight()Tile dimensions in pixelsTile Sheets and Maps
Map.PixelWidth() / PixelHeight()Total map size in pixelsTile Sheets and Maps
Map.TileAt(layer, col, row)Returns the tile ID at a grid cellTile Sheets and Maps
Scene.Stats()Returns RuntimeStats with visible tile count and upload countPipeline Overview

Camera

FeatureDescriptionDocs
Camera structPosition, size, zoom, follow target, bounds, and screen shakeCamera and Scrolling
Camera.WorldToScreen(x, y)Converts world coordinates to screen spaceCamera and Scrolling
Camera.UpdateFollow()Smoothly moves camera toward the follow targetCamera and Scrolling
Camera.ClampToBounds()Prevents the camera from leaving the world boundsCamera and Scrolling
Camera.AddTrauma(amount)Adds screen shake intensity (0 to 1)Camera and Scrolling
Camera.ShakeOffset()Returns the current shake displacement for drawingCamera and Scrolling

Game Systems

State Machine

FeatureDescriptionDocs
GameState interfaceEnter(), Update(), Draw(), Exit() for each screenState Machine
NewStateMachine(initial)Creates a state machine with an initial stateState Machine
StateMachine.Switch(state)Replaces the top state (calls Exit then Enter)State Machine
StateMachine.Push(state)Overlays a new state (for pause menus, dialogs)State Machine
StateMachine.Pop()Removes the top state and returns to the one belowState Machine
StateMachine.Update() / Draw()Delegates to the top stateState Machine

Timers

FeatureDescriptionDocs
NewTimer(frames)Creates a countdown timerTimers
Timer.Tick()Advances by one frame; returns true on the finishing frameTimers
Timer.Done() / Progress() / Remaining()Status queriesTimers
Timer.Reset() / ResetWith(frames)Restart the timerTimers
NewRepeatingTimer(interval)Creates a timer that fires every N framesTimers
RepeatingTimer.Tick()Returns true on trigger framesTimers
RepeatingTimer.Count()Returns how many times it has triggeredTimers
FeatureDescriptionDocs
NewMenu(items)Creates a D-pad-navigated menu from MenuItem entriesMenus
Menu.HandleInput()Reads the controller and moves the cursor; returns true on confirmMenus
Menu.Draw()Renders the menu with cursor indicatorMenus
Menu.MoveUp() / MoveDown()Manual cursor movement (skips disabled items)Menus
MenuItemStruct: Label, Disabled, OnConfirm callbackMenus

Save Data

FeatureDescriptionDocs
save.Storage interfaceUniform API for EEPROM, SRAM, and FlashRAMSave Data
save.ReadAll(s) / WriteAll(s, data)Read or write the entire save storageSave Data
save.Checksum(data)Additive checksum for save integritySave Data
Storage typesStorageEEPROM4K (512B), StorageEEPROM16K (2KB), StorageSRAM (32KB), StorageFlashRAM (128KB)Save Data

2D Math (math2d)

Vectors

FeatureDescriptionDocs
Vec22D vector with X, Y float32 fieldsVectors
Add, Sub, Scale, Negate, AbsArithmetic operationsVectors
Length, LengthSq, NormalizeMagnitude and normalizationVectors
Dot, Distance, DistanceSqProducts and distancesVectors
Lerp, Rotate, AngleInterpolation and rotationVectors
Min, MaxComponent-wise min/maxVectors

Rectangles

FeatureDescriptionDocs
RectAxis-aligned rectangle: X, Y, W, HRectangles
RectFromCenter(center, w, h)Creates a rect centered on a pointRectangles
ContainsPoint, ContainsRect, OverlapsSpatial queriesRectangles
Intersection, Expand, CenterRect operationsRectangles

Collision Detection

FeatureDescriptionDocs
AABBOverlap(a, b)Returns true if two rects overlapCollision Detection
AABBPenetration(a, b)Returns the minimum penetration vectorCollision Detection
AABBResolve(a, b)Pushes rect a out of rect bCollision Detection
AABBSweep(a, vel, b)Swept AABB test: returns hit time and normalCollision Detection
Layer, Collider, ColliderOverlapLayer-masked collision filteringCollision Detection

Easing Functions

FeatureDescriptionDocs
Clamp(v, lo, hi)Restricts a value to a rangeEasing Functions
Lerp(a, b, t)Linear interpolationEasing Functions
InvLerp(a, b, v)Inverse lerp (returns 0-1 ratio)Easing Functions
Remap(v, inMin, inMax, outMin, outMax)Maps a value from one range to anotherEasing Functions
MoveToward(current, target, maxDelta)Moves toward target by at most maxDeltaEasing Functions
EaseInQuad, EaseOutQuad, EaseInOutQuadQuadratic easingEasing Functions
EaseInCubic, EaseOutCubic, EaseInOutCubicCubic easingEasing Functions
SmoothStep(edge0, edge1, x)Hermite interpolationEasing Functions

Grid Utilities

FeatureDescriptionDocs
NewGrid[T](cols, rows)Creates a generic 2D gridGrid Utilities
Get, Set, Clear, FillCell access and bulk operationsGrid Utilities
ScanRow, ScanColRun-length scanning for matching groupsGrid Utilities
CountValue, FindAll, Neighbors4Queries and spatial helpersGrid Utilities

Random Numbers

FeatureDescriptionDocs
NewRand(seed)Creates a deterministic xoshiro128** PRNGRandom Numbers
Uint32, Intn(n), Float32Raw random valuesRandom Numbers
RangeInt(min, max), RangeFloat32(min, max)Range-bounded random valuesRandom Numbers
Bool()Random booleanRandom Numbers

3D Graphics

FeatureDescriptionDocs
math3d.Mat44x4 matrix with multiply, perspective, ortho, lookAt, translate, rotate, scale3D Math
math3d.Vec3 / Vec43D and 4D vectors with arithmetic, dot, cross, normalize3D Math
math3d.ViewportMaps clip-space to screen coordinates3D Math
scene3d.NewScene()Creates a 3D scene graphScene Graph
scene3d.NodeScene graph node with transform, children, and render functionScene Graph
scene3d.NewMeshNode(name, dl)Creates a node that renders a display listScene Graph
scene3d.NewPerspectiveCamera(...)Creates a perspective camera nodeScene Graph
scene3d.NewOrthoCamera(...)Creates an orthographic camera nodeScene Graph
scene3d.DrawScene(scene)Traverses the scene graph and rendersTriangle Rendering
gfx.DisplayListGPU command buffer for triangle renderingDisplay Lists

Low-Level

FeatureDescriptionDocs
dma.CartToRDRAM(offset, dst)DMA transfer from cartridge ROM to RDRAMDMA Transfers
dma.SRAMRead / SRAMWriteDirect SRAM access via DMADMA Transfers
dma.NewPool(base, size)Memory pool with head/tail allocationMemory Pools
dma.NewSegmentTable()Segment address translation tableDMA Transfers
rspq.NewQueue()RSP task queue for submitting microcode tasksRSP Task Queue
rspq.Load(microcode)Loads RSP microcodeRSP Task Queue
n64os.NewMessageQueue(size)OS-level message queue for event handlingN64 OS Primitives
n64os.NewScheduler(events, fn)Task scheduler for graphics and audioN64 OS Primitives
n64os.NewEventRouter()Routes hardware events to message queuesN64 OS Primitives
n64os.NewTimer(queue, msg, interval)OS-level timer with message deliveryN64 OS Primitives