pathfinding

package
v0.0.0-...-c728fae Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapTiles

func MapTiles(tiles []*Tile) map[image.Point]*Tile

MapTiles allows the access to a tile based on the point used

Types

type Tile

type Tile struct {
	Pos       string      // String representation of the position. Ex: (1, 3)
	Coords    image.Point // The number representation of the above. This is not in pixels
	Rectangle image.Rectangle
	Color     color.Color // What color the tile should be rendered with
	Cost      int         // How long it takes to get past the tile
}

Tile is a section of the screen for pathfinding

func GetCurrentTile

func GetCurrentTile(fPoint image.Point) *Tile

GetCurrentTile finds the tile that a point is in the most

func GetGoal

func GetGoal() *Tile

GetGoal returns the tile that the pathfinding should aim for

func GetPath

func GetPath(a *Tile, b *Tile) ([]*Tile, error)

GetPath uses A* pathfinding to get the best route from one tile to another

func MakeTiles

func MakeTiles(img image.RGBA) ([]*Tile, error)

MakeTiles creates a slice of tiles based on image dimensions

func (*Tile) GetCost

func (t *Tile) GetCost(screen image.RGBA) (int, error)

GetCost calculates the movement cost for a tile

func (*Tile) GetImage

func (t *Tile) GetImage(screen image.RGBA) image.Image

GetImage shows the image inside of a tile. The function should be passed the image of the whole screen

func (*Tile) PathEstimatedCost

func (t *Tile) PathEstimatedCost(to astar.Pather) float64

func (*Tile) PathNeighborCost

func (t *Tile) PathNeighborCost(to astar.Pather) float64

func (*Tile) PathNeighbors

func (t *Tile) PathNeighbors() []astar.Pather

PathNeighbors returns a slice of the tiles neighboring a tile

Jump to

Keyboard shortcuts

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