Documentation ¶
Index ¶
- Constants
- Variables
- func DistanceFromMe(d data.Data, p data.Position) int
- func DistanceFromPoint(from data.Position, to data.Position) int
- func GameCoordsToScreenCords(playerX, playerY, destinationX, destinationY int) (int, int)
- func MoveThroughPath(p *Pather, distance int, teleport bool)
- func RandomMovement()
- type AstarPather
- type Pather
- type Tile
- type World
Constants ¶
View Source
const ( // KindPlain (.) is a plain tile with a movement cost of 1. KindPlain uint8 = iota // KindBlocker (X) is a tile which blocks movement. KindBlocker // KindFrom (F) is a tile which marks where the path should be calculated // from. KindFrom // KindTo (T) is a tile which marks the goal of the path. KindTo // KindSoftBlocker (S) is a tile to fake some blocking areas with increased cost of moving, like Arcane Sanctuary platforms KindSoftBlocker )
Kind* constants refer to tile kinds for input and output.
Variables ¶
View Source
var KindCosts = map[uint8]float64{ KindPlain: 1.0, KindFrom: 1.0, KindTo: 1.0, KindSoftBlocker: 3.0, }
KindCosts map tile kinds to movement costs.
Functions ¶
func GameCoordsToScreenCords ¶
func MoveThroughPath ¶
func RandomMovement ¶
func RandomMovement()
Types ¶
type AstarPather ¶
type AstarPather []astar.Pather
type Pather ¶
type Pather struct { AstarPather Destination data.Position }
func GetClosestWalkablePath ¶
type Tile ¶
type Tile struct { // Kind is the kind of tile, potentially affecting movement. Kind uint8 // X and Y are the coordinates of the tile. X, Y int // W is a reference to the World that the tile is a part of. W World }
A Tile is a tile in a grid which implements Pather.
func (*Tile) PathEstimatedCost ¶
PathEstimatedCost uses Manhattan distance to estimate orthogonal distance between non-adjacent nodes.
func (*Tile) PathNeighborCost ¶
PathNeighborCost returns the movement cost of the directly neighboring tile.
func (*Tile) PathNeighbors ¶
func (t *Tile) PathNeighbors() []astar.Pather
PathNeighbors returns the neighbors of the tile, excluding blockers and tiles off the edge of the board.
type World ¶
type World [][]*Tile
func (World) FirstOfKind ¶
FirstOfKind gets the first tile on the board of a kind, used to get the from and to tiles as there should only be one of each.
Click to show internal directories.
Click to hide internal directories.