Documentation
¶
Overview ¶
Package gravity has bodies fall, stand on what bears them and leap: a character's controller, never rigid bodies.
Pull and Body ¶
NewPlugin gives the world its gravity, a Pull on the plugin's own entity: a knob an effect's Alter turns. A kind falls carrying a Body, which says how high it leaps; the plugin gives it a motion.Drift, the velocity motion carries it at beyond its walk. Whatever carries a Body is a unit of the board: unit.Airborne is on while it is in the air.
Two modes ¶
The pull's way is the mode, kept as long as the world lasts. Along Z (a world with heights) every step a body stands on the surface under its centre (Plugin.WithSurfaces, the board's ground.Surfaces), follows the ground down a slope within its reach, flies off a deck's edge, by a leap or a throw, and lands. Across X and Y (a platformer's side view, its Z the depth) a body is borne by whatever collision found it touching against the pull, a wall bearing nothing. Along Z a body falls slowing with its distance in levels from the finest any observer sees (lod.Slowing), across every step within two levels of it (lod.Contact), where collision runs.
Commands and Landing ¶
Leap and Away are an entity's own (act.Self.Do, driving.Jump): a leap throws a standing body up to its Body's height, an Away throws it off across and up, away from the subject of the moment it is given on. A Landing is told the rules the plugin hosts once as a body lands, with how fast it fell (HarderThan). Run the plugin's RunPlan right after collision's.
Vocabulary ¶
Moments, for a role's rules: Landing (once as a body lands; its word HarderThan). Knobs, for an effect's Alter: Pull (on the plugin's own entity). Commands, an entity's own: Leap, Away (aimed at the moment's subject, host.Aimed).
Index ¶
- func HarderThan(speed float32) cond.Word[Landing]
- type Away
- type Body
- type Config
- type Landing
- type Leap
- type Plugin
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Install(ctx plugin.Installer) error
- func (p *Plugin) Name() string
- func (p *Plugin) Queues() []command.CommandQueue
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) WithSurfaces(surfaces func() ground.Surfaces) *Plugin
- type Pull
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Away ¶
Away is the command an entity gives itself to be thrown off at Speed across, rising Rise high first. It is host.Aimed: thrown away from the subject of the moment it is given on, else back from the way it faces.
type Body ¶
type Body struct{ Leap float32 }
Body makes an entity fall under the Pull, stand on what bears it and leap; Leap is how high it leaps, in world units (0, not at all). Its drift and, with heights, its altitude are written by gravity alone.
type Config ¶
type Config struct {
// Pull is the pull the world begins under, along Z or across X and Y; zero, the Earth's as its
// figures feel it: −Z in a world with heights, +Y (down the screen) in a flat one.
Pull Pull
}
Config is how a world's gravity begins.
type Landing ¶
Landing is a body coming down on what bears it, told once as it lands; Speed is how fast it fell, in world units a second.
type Leap ¶
type Leap struct{}
Leap is the command an entity gives itself to leap as high as its Body says; one in the air does not.
type Plugin ¶
Plugin is gravity over the entities of a world that carry a Body: every step it carries each by its drift, stands it on what bears it, lets it fall and lands it, a Landing for the rules it hosts.
func NewPlugin ¶
NewPlugin builds the gravity of w as cfg begins it, m carrying what it drifts: along Z, a body falling to the ground, or across X and Y, a side view's. A pull both ways, or along Z in a flat world, panics.
func (*Plugin) DefaultBindings ¶
DefaultBindings are none: a key leaps through driving.Jump.
func (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
EventHandler is nil: gravity reads no input.
func (*Plugin) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are where Leap and Away land.
func (*Plugin) Serializable ¶
func (p *Plugin) Serializable() plugin.Serializable
Serializable is nil: the pull and the drifts are on the entities.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
planar
Package planar is a body's fall across the plane, a platformer's: the pull any way across it, the body borne by whatever collision found it touching against the pull.
|
Package planar is a body's fall across the plane, a platformer's: the pull any way across it, the body borne by whatever collision found it touching against the pull. |
|
vertical
Package vertical is a body's fall along Z: a step of the pull along the vertical between the surface under its feet and the slab over its head.
|
Package vertical is a body's fall along Z: a step of the pull along the vertical between the surface under its feet and the slab over its head. |