move

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package move advances path-following agents across a shared flow field.

Agents are intentionally generic: tower-defense enemies use them today; player-controlled units can reuse the same Transform + Agent stores later. Combat stats (health, reward, armor) stay in game-specific components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FollowFlow

func FollowFlow(
	agents *ecs.Store[Agent],
	transforms *ecs.Store[Transform],
	field *pathing.Field,
	g *grid.Grid,
	tileSize float64,
	dt float64,
)

FollowFlow moves every entity that has both Agent and Transform along field.

Each tick:

  1. Refresh the cell cache from world position.
  2. Aim at the center of the next flow-field cell (or stop at the exit).
  3. Integrate position by Speed * dt toward that target.

Agents on unreachable tiles do not move. tileSize must match the grid used to build field. g may be nil if you only need field sampling (cell refresh still uses tileSize alone).

Types

type Agent

type Agent struct {
	Speed        float64
	CellX, CellY int
}

Agent is path-following state for enemies and later player units.

CellX/CellY cache the tile the agent occupies; FollowFlow refreshes them when the world position crosses a tile boundary.

type Transform

type Transform struct {
	X, Y float64
}

Transform is world-space position. Shared by any moving unit.

Jump to

Keyboard shortcuts

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