castrum

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithFixedTPS

func WithFixedTPS(tps int) option

WithFixedTPS sets the fixed simulation rate in ticks per second. Default is 60. Invalid values are reported by New.

func WithMaxFrameTime

func WithMaxFrameTime(d time.Duration) option

WithMaxFrameTime sets the per-frame accumulator clamp, the spiral-of-death guard. Default is 250ms. Invalid values are reported by New.

func WithMaxTicksPerFrame

func WithMaxTicksPerFrame(n int) option

WithMaxTicksPerFrame sets how many fixed ticks may run in one display frame before excess accumulated time is dropped. Default is 5. Invalid values are reported by New.

func WithTitle

func WithTitle(title string) option

WithTitle sets the game title. The active runner displays it.

Types

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game is the core engine: configuration, schedules, and the fixed loop. It is runner-agnostic: a Runner drives it and owns the window, the draw surface, and input.

func New

func New(opts ...option) (*Game, error)

New creates a Game from defaults overridden by opts. The option constructors never fail; all validation happens here in a single pass, and New returns an error for invalid values, leaving no half-built game behind.

func (*Game) AddSystem

func (g *Game) AddSystem(phase core.Phase, name string, system core.System) error

AddSystem binds systems to a schedule under a name. Systems run in registration order. The name identifies the registration in error messages and will serve as the handle for future ordering constraints; Returns an error if the name is empty.

func (*Game) Advance

func (g *Game) Advance(elapsed time.Duration) error

Advance runs one display frame: ScheduleFrame, then every fixed tick due for elapsed, clamped to MaxFrameTime. Runners call it once per platform frame with the time since the previous call.

func (*Game) Alpha

func (g *Game) Alpha() float64

Alpha returns the fixed-loop remainder over the tick interval, in [0, 1).

func (*Game) Context

func (g *Game) Context() *core.Context

Context returns the live context. Runners use it when running their draw systems; game code receives it as a system argument.

func (*Game) Options

func (g *Game) Options() Options

Options returns a copy of the converged configuration. The runner reads game identity (title) from it.

func (*Game) Quit

func (g *Game) Quit()

Quit requests termination. The active runner observes it and stops.

func (*Game) Quitting

func (g *Game) Quitting() bool

Quitting reports whether Quit was called.

func (*Game) Run

func (g *Game) Run(r Runner) error

Run hands control to r. It may be called once; a second call returns an error.

func (*Game) Startup

func (g *Game) Startup() error

Startup runs the ScheduleStartup systems once. Runners call it before entering the platform loop; a second call returns an error.

func (*Game) World

func (g *Game) World() *core.World

World returns the game's world: entities and resources live there.

type Options

type Options struct {
	// Title is the game's identity; the runner displays it.
	Title string

	// Simulation contract: developer decisions, not player preferences.
	FixedTPS         int
	MaxFrameTime     time.Duration
	MaxTicksPerFrame int
	// contains filtered or unexported fields
}

Options is the pure-data configuration New converges option values into. It carries only data, never callbacks or handles, so a future file-backed Config type can map onto it 1:1. Populate it through New and the [With*] constructors; direct construction skips defaults and validation.

Window and graphics settings do not live here: they belong to the runner.

func (Options) FixedDT

func (o Options) FixedDT() time.Duration

FixedDT returns the derived interval between fixed ticks.

type Runner

type Runner interface {
	Run() error
}

Runner drives a Game: it owns the platform loop, the draw surface, and input, and calls the Game loop hooks. Run blocks until the game quits.

Directories

Path Synopsis
Package asset loads, decodes, and caches game assets from a filesystem.
Package asset loads, decodes, and caches game assets from a filesystem.
Package core provides the foundational structures and mechanisms for managing the game world, including entities and resources, and their lifecycle within the world.
Package core provides the foundational structures and mechanisms for managing the game world, including entities and resources, and their lifecycle within the world.
Package ebitrun is the default castrum Runner, backed by Ebitengine.
Package ebitrun is the default castrum Runner, backed by Ebitengine.
examples
primitive command
Command primitive demonstrates the shape drawables as a spectrum: one row per shape kind - rect, circle/ellipse, line - and one column per variant - filled, outlined, spinning, stretched by the transform's scale, half-faded.
Command primitive demonstrates the shape drawables as a spectrum: one row per shape kind - rect, circle/ellipse, line - and one column per variant - filled, outlined, spinning, stretched by the transform's scale, half-faded.
wander command
Command wander demonstrates the v0.1.0 renderer: an atlas sprite wanders to random screen points at fixed ticks, the engine renders it interpolated between ticks, and a user DrawFunc draws an overlay above the engine-rendered world.
Command wander demonstrates the v0.1.0 renderer: an atlas sprite wanders to random screen points at fixed ticks, the engine renders it interpolated between ticks, and a user DrawFunc draws an overlay above the engine-rendered world.
internal
ecs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL