forest

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 24 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

Overview

Package forest plants forests over the board: fields of trees standing as a camera comes near and folding into the world's sheets as it goes.

NewPlugin takes the world and the board, whose cells and heights a forest reads. It has no pass of its own: its trees come and go by the world's moments of an aggregate.

Kinds of trees

A game defines its kinds of trees in the Kinds section (Plugin.Types, Types.Define a Spec): how tall a tree stands and how wide its crown, how it looks, how it casts its shade, how much it bends in the wind, whether it stops what collides, and the game's roles it plays beside TreeRole. A tree is a part of its forest standing for good (world.Fixed), going as its sector folds. At L2 it stands in relief as a billboard of its Side, its top leaning with the wind's gusts as far as its Sway says, or as a body of it on the four sides and over the top of its box where its Spec says Body, at L3 as a billboard of its Top; from L4 out the world's sheets hold it as planted. A look left out is drawn of its Colours. A Spec with Parts is a tree with a body (world.Body), its parts in the paints Leaves and Wood: it stands whole in relief as far as the world's bodies reach and as a card of itself beyond, its Side and its Top photographed of it. Its looks are whole, drawn in render's cutout pass (world.Slot.Cutout), and give way (world.Slot.GivesWay): what a game's look has uncovered (world.Slot.Uncovered) shows through the tree before it or over it, which is left out in part round it, before the cameras the world's settings say (world.GiveWay, world.GiveWayRiding). Types.Entry is a tree for a game's own rule to stand where no forest plants it.

Stands

A forest is a game's kind with world.Aggregate and world.Field playing a role the plugin makes in the Rules section (Plugin.Stands, Stands.Define a Stand): each of its sectors come down to L3 plants trees over the kinds of cells the Stand names, as many a cell as its Density, each plot sown by the forest's seed (lod.Seed) and its tree drawn by weight among the [Share]s of the Mix growing at the height of the ground there. A forest plants the same trees each time, and the world previews them into its sheets before anyone comes near. A Stand's When has an effect of the forest's choose between two stands; Stands.Felled tells a forest folding short of its trees.

Figures

A Figure is a kind of forest in one piece: Define its kinds of trees on the plugin's Types and its own kind, Look its own look on the world's atlas, and, Stateful or Ruled, its effects and rules, its stands among them. Plugin.Figures, called in the Stage's Figures link, hands them on to the world's figures; Plugin.World and Plugin.Board are what they stand on.

Vocabulary

Roles: TreeRole, every tree's. Words: Stands.Felled, of a world.Fold.

Index

Constants

View Source
const (
	Leaves = iota
	Wood
)

The paints of a tree's body, which a Part of its Spec names: Leaves, in its Colours' Crown, dotted with their Leaves and with what it Bears, and Wood, in their Trunk.

View Source
const DefaultDensity = 1.5

DefaultDensity is how many trees a cell a Stand plants where its Density is zero.

View Source
const TreeRole = "forest.tree"

TreeRole is the role every tree plays, the plugin's own: a tree goes as its sector folds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Colours

type Colours struct {
	Crown  color.RGBA
	Leaves color.RGBA
	Trunk  color.RGBA
	// Bears is its blossom or its fruit, dotted over its body's leaves; nothing where zero.
	Bears color.RGBA
}

Colours are what a tree's looks are drawn in where its Spec gives no drawer of its own, and its body is painted in: a dark green crown on a brown trunk where they are zero.

type Figure

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

Figure is a kind of forest in one piece: its kinds of trees defined on the plugin's Types and its own kind in the Kinds section, its look 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, its Stands among them, Ruled.

type Plugin

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

Plugin plants forests over the board: the kinds of trees a game defines on its Types, planted by the rules its Stands make as a forest's sectors come near and gone as they fold.

func NewPlugin

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

NewPlugin builds the forest plugin over w and the board brd, which a forest's cells and heights are read off.

func (*Plugin) Board

func (p *Plugin) Board() *board.Plugin

Board is the board the forests grow on.

func (*Plugin) EventHandler

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

EventHandler is nil: the forest reads no input.

func (*Plugin) Figures

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

Figures notes the kinds of forests 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(plugin.Installer) error

Install wires nothing: the trees grow and fold by the world's moments.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) RunPlan

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

RunPlan does nothing: the forest has no pass of its own.

func (*Plugin) Serializable

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

Serializable is nil: a tree is an entity, saved as any, and a forest's state its effects.

func (*Plugin) Stands

func (p *Plugin) Stands() *Stands

Stands makes the roles that plant a game's forests.

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 trees.

func (*Plugin) World

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

World is the world the forests stand in.

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 Share

type Share struct {
	Tree     string
	Weight   float32
	From, To float32
}

Share is a kind of tree in a Stand's Mix: its name on the Types, its Weight against the others growing where it does (1 where it is zero), and the band of the ground's height it grows in, From up to To in world height units, zero for no bound.

type Spec

type Spec struct {
	Height float32
	// Crown is the side of the tree's box.
	Crown float32
	// Trunk is the share of its Height under its crown where its Side is drawn of its Colours.
	Trunk   float32
	Colours Colours
	// Top is its crown seen from above, at L3 and in the world's sheets; drawn of its Colours
	// where it is nil.
	Top render.SpriteDrawer
	// Side is its trunk and crown seen from the side, at L2; drawn of its Colours where it is nil.
	Side render.SpriteDrawer
	// Shadow is how it casts and takes shade, Baked taking all where it is zero.
	Shadow light.Shadow
	// Solid has it a post nothing walks through, which what collides meets.
	Solid bool
	// Body has it drawn at L2 as a body, its Side on the four faces and over the top of its box;
	// a billboard of its Side unless set.
	Body bool
	// Sway is how much it bends in the wind, 0 not at all to 1 as far as the wind blows it.
	Sway float32
	// Parts are its body, each in the paint Leaves or Wood, world.MaxParts at most: whole in
	// relief near the camera, a card of it beyond, its Side photographed of it and its Top where
	// that is nil (world.Atlas.AddBody); none, the billboards of its Side and its Top.
	Parts []world.Part
	// Roles are the game's roles it plays besides TreeRole.
	Roles []string
}

Spec is what a kind of tree is: how tall it stands and how wide its crown, in world units, how it looks, casts its shade and bends in the wind, whether it stops what collides, and the game's roles it plays.

type Stand

type Stand struct {
	// Cells are the names of the kinds of cells its trees grow on; every cell where it names none.
	// No tree stands on a way's band or under a deck, nor within half the widest crown of the Mix
	// and a quarter of the way's width of its band.
	Cells []string
	// Density is how many trees a cell it plants, DefaultDensity where it is zero.
	Density float32
	// Jitter is how far a tree strays from its plot each way, a share of the plots' spacing up to
	// a half.
	Jitter float32
	// Mix is the kinds of trees it plants, each plot's drawn by weight among those growing at the
	// height of the ground there.
	Mix []Share
	// When is what the forest must hold for the stand to plant, an effect of its own say; always
	// where it is nil.
	When cond.Cond
}

Stand is how a forest plants its trees: on which kinds of cells, how many a cell, how far each strays from its plot, and which kinds of trees at which heights of the ground.

type Stands

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

Stands makes the roles that plant a game's forests, in the Rules section.

func (*Stands) Define

func (s *Stands) Define(name string, stand Stand, rules ...act.Rule)

Define defines the role named name, with rules beside, which a kind of forest (a world.Field) plays to plant its trees as stand says in each sector of it come down to L3.

func (*Stands) Felled

func (s *Stands) Felled(stand Stand) cond.Word[world.Fold]

Felled is the word of a stretch of a forest folding with fewer trees than stand plants there: some were felled, or went otherwise.

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 tree defined.

func (Type) ID

func (t Type) ID() kind.ID

ID is the kind's in the world, its trees' world.Base.TypeID.

func (Type) Name

func (t Type) Name() string

Name is what the kind of tree is called.

func (Type) Spec

func (t Type) Spec() Spec

Spec is what the kind of tree is.

type Types

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

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

func (*Types) Define

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

Define registers the kind of tree named name, as spec says: a part of its forest standing for good, playing TreeRole and spec's Roles.

func (*Types) Entry added in v0.22.0

func (t *Types) Entry(name string) kind.Entry

Entry is one tree of the kind named name, for a game's own rule to stand where no forest plants it (world.SpawnPart); a name no kind of tree is defined as by the time the looks are declared panics.

func (*Types) Named

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

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

Jump to

Keyboard shortcuts

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