bridges

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 30 Imported by: 1 module, 1 package

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

Overview

Package bridges builds bridges by one set of rules, package site's, whoever builds them: a level's file, a player with a bridge in hand, a map maker.

NewPlugin takes the world, the board and the Config: where a bridge may stand (site.Rules) and the kind of bridge a player builds. A game defines its kinds of bridges in the Kinds section (Plugin.Types, Types.Define a Spec): whom the deck carries and how much it bears, how wide and thick it is, its railings and its piers.

A bridge is its parts

A bridge is entities standing on the board, saved as any: a piece of deck on every cell from head to head, a band with its railings, and over a map in relief a pier between every two spans casting its Baked shadow (light.Shadow), headed along the bridge (world.Velocity), so a pier's body stands square to the deck. Over them stands its handle, "<name>.whole", holding no cell and drawn at no level, which casts the deck's shadow whole, seen through by sight, and takes its pieces with it as it goes (world.Whole). Type.Deck and Type.Pier are their looks' slots for a scene's atlas. They are world.Fixed: from L4 out the world's sheets hold them at their tops, and by a sector drawn finer they are drawn alive at its level, so a bridge stays whole and level across the seam.

A level's bridges

A line of a level's file `{kind: bridge, from: [x, y], to: [x, y]}` is a bridge from head to head: Write.Spawn builds every one in the Spawn section and fails with the line of one that may not stand.

A bridge in a player's hand

Plugin.DefaultBindings have Shift+B take a bridge in hand (Tool); while the player holds it, the cursor lays the bridge out (Aim), a left click marks a head (Mark) and a right click or Esc puts the bridge down. [Plugin.Renderer] draws the bridge in hand, yellow where it may not stand (Plugin.Reason says why), green where it may. Plugin.Window asks "Build the bridge?": Build has it built at the next step of the simulation, its heads levelled on the ground Plugin.WithShaper gives, Cancel builds nothing. A bridge confirmed waits for its step in Resources.Orders, saved with the game.

Figures

A Figure is a kind of bridge in one piece: Define its Spec on the plugin's Types, Look the looks of its deck and pier on the world's atlas, and, Stateful or Ruled, its own effects and rules. Plugin.Figures, called in the Stage's Figures link, hands them on to the world's figures, which the Stage leads through its sections; Plugin.World is the world they stand in.

Vocabulary

Marks: world.Whole on a bridge's handle, world.PieceOf on its pieces. Commands, a player's with the bridge tool in hand: Aim, Mark, Build, Cancel.

Index

Constants

View Source
const Tool control.Tool = "bridge"

Tool is a bridge in a player's hand, for control.Take.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aim

type Aim struct{ At geom.Vec }

Aim is where the cursor of a player holding the bridge points: where the bridge runs to.

func (Aim) Command

func (Aim) Command()

type Build

type Build struct{}

Build builds the bridge its player was asked about.

func (Build) Command

func (Build) Command()

type Cancel

type Cancel struct{}

Cancel builds nothing of the bridge its player was asked about, the first head still laid.

func (Cancel) Command

func (Cancel) Command()

type Config

type Config struct {
	Rules  site.Rules
	Builds string
}

Config is where bridges may stand (Longest 3 where Rules say none) and the kind of bridge a player's Tool builds, the first defined for none.

type Figure

type Figure interface {
	Define(p *Plugin)
	Look(a *world.Atlas, p *Plugin)
}

Figure is a kind of bridge in one piece: its Spec defined on the plugin's Types in the Kinds section, the looks of its deck and pier declared on the world's atlas in a scene. One with states of its own is Stateful, one with roles and rules of its own Ruled.

type Mark

type Mark struct{ At geom.Vec }

Mark lays a bridge's head at the world point At: the first where the bridge begins, the next its other end, asking whether to build it; the first again lifts it.

func (Mark) Command

func (Mark) Command()

type Order added in v0.17.0

type Order struct {
	Kind string
	Plan site.Bridge
}

Order is a bridge its player confirmed (Build), built at the next step of the simulation: the name of its kind of bridge (Types.Named) and its plan.

type Plugin

type Plugin struct {
	*world.Self
	Res Resources
	// contains filtered or unexported fields
}

Plugin builds bridges by one set of rules, a level's and a player's, as entities standing on the board.

func NewPlugin

func NewPlugin(w *world.Plugin, brd *board.Plugin, cfg Config) *Plugin

NewPlugin builds the bridges plugin over w and brd.

func (*Plugin) DefaultBindings

func (p *Plugin) DefaultBindings() []control.Binding

DefaultBindings are Shift+B taking the bridge in hand and, while it is held, the cursor aiming it, a left click marking a head and a right click or Esc putting it down.

func (*Plugin) EventHandler

func (p *Plugin) EventHandler() control.EventHandler

func (*Plugin) Figures

func (p *Plugin) Figures(figures ...Figure)

Figures notes the kinds of bridges among the world's figures, which the Stage leads through its sections. Called in the Stage's Figures link.

func (*Plugin) Install

func (p *Plugin) Install(ctx plugin.Installer) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Populate

func (p *Plugin) Populate() error

Populate holds the bridges a level's file laid to the Rules; one that may not stand fails with its line.

func (*Plugin) Queues

func (p *Plugin) Queues() []command.CommandQueue

Queues are the plugin's command queues: Aim, Mark, Build and Cancel.

func (*Plugin) Reason

func (p *Plugin) Reason() *ui.Element

Reason is a label saying why the bridge in a player's hand may not stand where it points.

func (*Plugin) Restore added in v0.17.0

func (p *Plugin) Restore()

Restore takes the Resources loaded.

func (*Plugin) RunPlan

func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)

RunPlan carries out the players' commands at once and builds the bridges confirmed in the simulation.

func (*Plugin) Serializable

func (p *Plugin) Serializable() plugin.Serializable

Serializable is the plugin's Resources, kept whole; a bridge built is its parts, saved as entities.

func (*Plugin) String

func (p *Plugin) String() string

func (*Plugin) Types

func (p *Plugin) Types() *Types

Types is the plugin's register of the kinds of bridges.

func (*Plugin) Window

func (p *Plugin) Window() *ui.Element

Window is the window asking a player whether to build the bridge it marked out, shown while it asks.

func (*Plugin) WithShaper

func (p *Plugin) WithShaper(s ground.Shaper) *Plugin

WithShaper gives the plugin the ground a player's bridge levels its heads on; without it a bridge stands only where its heads lie flat at its deck already.

func (*Plugin) World

func (p *Plugin) World() *world.Plugin

World is the world the bridges stand in.

func (*Plugin) Write added in v0.4.0

func (p *Plugin) Write() *Write

Write changes the bridges standing, on the game's goroutine.

type Resources added in v0.17.0

type Resources struct{ Orders []Order }

Resources is the state of bridges, saved with the game whole: the bridges ordered and not yet built.

type Row

type Row struct {
	From cell.ID `yaml:"from"`
	To   cell.ID `yaml:"to"`
}

Row is a bridge as a level's file writes it: from the head From to the head To.

type Ruled

type Ruled interface{ Rules(p *Plugin) }

Ruled is a Figure with roles and rules of its own, defined in the Rules section.

type Spec

type Spec struct {
	Allows    cell.Domain
	Load      float32
	Width     float32
	Thickness float32
	Pace      float64
	Rail      cell.Rail
	Pier      float32
}

Spec is what a kind of bridge is: whom its deck carries (Allows, at Pace; 0 the ground's) and how heavy they may be (Load, kg; 0 any), how wide and thick its deck is, its railings and how wide a pier is.

type Stateful

type Stateful interface{ Effects(p *Plugin) }

Stateful is a Figure with effects of its own, defined in the Effects section.

type Type

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

Type is a kind of bridge defined.

func (Type) Deck

func (t Type) Deck() render.SpriteID

Deck is the atlas slot its deck's pieces are drawn from, a sprite laid flat.

func (Type) Name

func (t Type) Name() string

Name is what the kind of bridge is called.

func (Type) Pier

func (t Type) Pier() render.SpriteID

Pier is the atlas slot its piers are drawn from, standing; a bridge over a map without relief stands on none.

func (Type) Spec

func (t Type) Spec() Spec

Spec is what the kind of bridge is.

type Types

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

Types is the register of the kinds of bridges, defined on the Stage's kinds.

func (*Types) Define

func (t *Types) Define(name string, spec Spec)

Define registers the kind of bridge named name, as spec says, with the kinds of its parts, "<name>.deck" and "<name>.pier", and of its handle, "<name>.whole".

func (*Types) Named

func (t *Types) Named(name string) Type

Named is the kind of bridge defined as name; an unknown name panics.

type Write added in v0.4.0

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

Write changes the bridges standing, on the game's goroutine.

func (*Write) Spawn added in v0.4.0

func (w *Write) Spawn(level *board.Level) error

Spawn builds every bridge a level's file has, a line `{kind: <a kind of bridge>, from: [x, y], to: [x, y]}`, its deck at its first head's level. One the Rules refuse fails Populate with its line.

Directories

Path Synopsis
Package site is where a bridge may stand: Plan a bridge from one head to another over a Ground under the Rules, or say why not (Refusal).
Package site is where a bridge may stand: Plan a bridge from one head to another over a Ground under the Rules, or say why not (Refusal).

Jump to

Keyboard shortcuts

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