driving

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 26 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 driving drives units by hand: a player's keys, or an entity's own commands, walk, turn, strafe, brake and back a unit away, leap, and fly one that flies.

Commands and the hand

Ahead walks the units on the way each faces (Sprint urging them on), Back brakes them and backs them away, Turn turns them, Strafe walks them across the way they face, facing on, Toward walks them the way of the screen, Jump has them leap (JumpKey binds it). Each is given every tick its key is held, and a tick's commands add up into a hand. A player's hand, through the camera its commands name, is on the unit that camera is fastened to, else on the units the player has selected and owns; an entity's command for itself (act.Self.Do) is its own hand. The hand is written into the unit's steering.Driven and the unit marked Driving; asked to go more than 45 degrees off its way, a walking unit brakes first and turns, then walks; a tick with no hand on it brakes it, and it is let go once it stands. With Plugin.WithTap a key held no longer than that on a standing unit only turns it the way of the key; held longer, it walks.

Keys

Tank are four keys driving the unit as one sits in it (Left and Right turn), Shooter four driving it as a shooter does (Left and Right strafe, the mouse turns) and Compass four walking it the way of the screen; each holds in the fastenings of the camera it says (In), so the same keys may pan a free camera and drive a ridden unit. DefaultKeys, the plugin's DefaultBindings, are a Shooter of W, S, A and D inside the unit, a Compass of them behind it (the way the screen lies, as the camera turns it: camera.Headed), a Tank of the arrows behind it, and Space to jump inside and behind; a split screen gives each player its own Compass.

Ground and navigation

Given a board (Plugin.WithGround) a driven unit never walks onto ground its domain may not stand on nor takes a step the board's mobility refuses (a slope too steep for it), and its cell and its hold on the occupancy follow it; beyond that one under gravity is held back by physics alone. A plugin that keeps units apart hands the driving its Keeping (Plugin.WithKeeping, as navigation does): whether a unit may walk on into the cell ahead, and whether something else steers it, which the driving leaves be with no hand on it.

Vocabulary

Commands, a player's through its camera or an entity's own: Ahead, Back, Turn, Strafe, Toward, Jump. It writes the knob steering.Driven and the marker Driving.

Index

Constants

View Source
const Driving tag.Tag[States] = 0

Driving is on while a hand drives the unit; once no hand is on it and it stands, or something else steers it, the driving lets it go.

Variables

This section is empty.

Functions

func JumpKey

func JumpKey(key control.Key) control.Binding

JumpKey is key pressed, whatever else is held, into a Jump of the camera the player looks through: sprinting with Shift, one still jumps.

Types

type Ahead

type Ahead struct {
	Camera camera.Camera
	Sprint bool
}

Ahead walks the units the hand is on the way each faces, Sprint urging them on; given every tick its key is held. Camera, the one it was given through, says which units the hand is on: the one it is fastened to, else those the player has selected.

func (Ahead) Command

func (Ahead) Command()

type Back

type Back struct{ Camera camera.Camera }

Back brakes the units the hand is on to a stop and then backs them away facing as they do.

func (Back) Command

func (Back) Command()

type Compass

type Compass struct {
	Up, Down, Left, Right control.Key
	In                    camera.How
}

Compass are four keys held walking the units the way of the screen: up, down, left, right, as the camera lays it (up the way it looks ahead, camera.Headed), the units turning to face it; with Shift, sprinting. In says in which fastenings of the camera they hold (zero, every one); KeyUnknown leaves one unbound.

func (Compass) Bindings

func (k Compass) Bindings() []control.Binding

Bindings are the four keys held into Toward of the camera the player looks through.

type Jump

type Jump struct{ Camera camera.Camera }

Jump has each unit the hand is on leap (gravity.Leap), as high as its gravity.Body says.

func (Jump) Command

func (Jump) Command()

type Keeping

type Keeping interface {
	// MayStep reports whether the unit id, standing at pos in its cell at, moving in domain, may
	// walk on into the cell ahead along heading on level.
	MayStep(id uid.UID64, pos world.Position, at, ahead cell.ID, level cell.Level,
		domain cell.Domain,
		heading geom.Vec) bool
	// Ordered reports whether id is steered along a route of its own: with no hand on it, the
	// driving leaves it be.
	Ordered(id uid.UID64) bool
}

Keeping is who else may stand in a driven unit's way, and whom something else steers: the navigation's spacing, which navigation hands over as it is made (WithKeeping).

type Keys

type Keys interface {
	Bindings() []control.Binding
}

Keys are a set of keys driving a player's units, bound as one and in chords, sprinting with Shift: Tank, Shooter or Compass.

func DefaultKeys

func DefaultKeys() []Keys

DefaultKeys drive the unit the camera is fastened to: W, S, A and D riding inside it as a shooter's, behind it as a compass's (the way the screen lies, the mouse turning the camera); the arrows a tank's behind it.

type Plugin

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

Plugin drives units by hand: the commands Ahead, Back, Turn and Toward, summed a tick into each hand and carried out on the units the hand is on.

func NewPlugin

func NewPlugin(
	worldPlugin *world.Plugin,
	m *motion.Plugin,
	selectionPlugin *selection.Plugin,
) *Plugin

NewPlugin builds the driving over worldPlugin's units, moved by m, a player's hand on those it has selected in selectionPlugin while its camera is fastened to none.

func (*Plugin) DefaultBindings

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

DefaultBindings are DefaultKeys, the keys driving the unit the camera is fastened to, and Space to jump riding inside it or behind it.

func (*Plugin) EventHandler

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

EventHandler is nil: a player's bindings issue the commands.

func (*Plugin) Install

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

func (*Plugin) KindTemplates

func (p *Plugin) KindTemplates(r *kind.Roster)

KindTemplates is what driving asks of the kinds a game defines: of a unit, the profile it is driven by and its driving's markers.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Queues

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

Queues are where the hand's commands land.

func (*Plugin) RunPlan

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

RunPlan puts this tick's hands on the units at once and carries them out in the simulation; call it after navigation's, whose orders a hand ends.

func (*Plugin) Serializable

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

Serializable is nil: the driving keeps nothing but the units' own components.

func (*Plugin) WithGround

func (p *Plugin) WithGround(b *board.Plugin) *Plugin

WithGround has the driven units walk the board: never onto ground their domain may not stand on, their cell and their hold on the occupancy following them. Call it before Use.

func (*Plugin) WithKeeping

func (p *Plugin) WithKeeping(k Keeping) *Plugin

WithKeeping has k say who else is in a driven unit's way and whom it steers itself (navigation calls it as it is made). Call it before Use.

func (*Plugin) WithTap

func (p *Plugin) WithTap(d time.Duration) *Plugin

WithTap has a key held no longer than d on a standing unit only turn it the way of the key (Toward); held longer, it walks. Zero, it walks at once. Call it before Use.

type Shooter

type Shooter struct {
	Ahead, Back, Left, Right control.Key
	In                       camera.How
}

Shooter are four keys held driving the units as a shooter does: Ahead walks on (with Shift, sprints), Back brakes and backs away, Left and Right strafe, facing on — the mouse turns. In says in which fastenings of the camera they hold (zero, every one); KeyUnknown leaves one unbound.

func (Shooter) Bindings

func (k Shooter) Bindings() []control.Binding

Bindings are the four keys held into Ahead, Back and Strafe of the camera the player looks through.

type States

type States struct{}

States is the family of a unit's driving markers. The plugin gives it to every unit the world's roster makes; a unit without it gets it the first time it is needed.

type Strafe

type Strafe struct {
	Camera camera.Camera
	Way    int8
}

Strafe walks the units the hand is on across the way each faces, facing on: Way 1 to the right, -1 to the left.

func (Strafe) Command

func (Strafe) Command()

type Tank

type Tank struct {
	Ahead, Back, Left, Right control.Key
	In                       camera.How
}

Tank are four keys held driving the units as one sits in them: Ahead walks on (with Shift, sprints), Back brakes and backs away, Left and Right turn. In says in which fastenings of the camera they hold (camera.Inside riding in the unit, camera.Behind following it, camera.Outside looking from anywhere; zero, every one); KeyUnknown leaves one unbound.

func (Tank) Bindings

func (k Tank) Bindings() []control.Binding

Bindings are the four keys held into Ahead, Back and Turn of the camera the player looks through.

type Toward

type Toward struct {
	Camera camera.Camera
	Way    geom.Vec
	Sprint bool
}

Toward walks the units the hand is on the way Way says, as the screen lies (up the screen the way Camera looks ahead where it has a heading, camera.Headed): they turn to it and go, Sprint urging them on. Several in one tick add up — up and right walk them up and right.

func (Toward) Command

func (Toward) Command()

type Turn

type Turn struct {
	Camera camera.Camera
	Way    int8
}

Turn turns the units the hand is on: Way -1 anticlockwise, 1 clockwise.

func (Turn) Command

func (Turn) Command()

Jump to

Keyboard shortcuts

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