world

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(v1, v2 pixel.Vec) float64

Distance between two vectors

func ManDist

func ManDist(v1, v2 pixel.Vec) float64

func Sqrt

func Sqrt(x float64) float64

Types

type Being

type Being interface {
	ID() uint64
	X() float64
	Y() float64
	Type() types.Type
	MoveTo([2]float64)

	Health() float64
	SetHealth(float64)
	DealDamage(from uint64, damage float64) (healthAfter float64)
}

Being / Entity: a thing with distinct and independent existence. also see Object

func NewStaticEntity

func NewStaticEntity(uid uint64, beingtype types.Type, atx, aty float64) Being

NewStaticEntity returns a ... if static entity uid or beingtype are zero they will randomly be generated

type Beings

type Beings []Being

Beings Sort entities export

func (Beings) Len

func (entities Beings) Len() int

func (Beings) Less

func (entities Beings) Less(x, y int) bool

func (Beings) String

func (entities Beings) String() string

func (Beings) Swap

func (entities Beings) Swap(x, y int)

type Object

type Object interface {
	Pos() pixel.Vec
	Name() string
	Type() types.Type
}

type P

type P struct {
	PID uint64
	PX  float64
	PY  float64
	PT  types.Type
}

func (P) Encode

func (p P) Encode(b []byte) (n int, err error)

func (P) ID

func (p P) ID() uint64

func (P) MoveTo

func (p P) MoveTo(d [2]float64)

func (P) Type

func (p P) Type() types.Type

func (P) X

func (p P) X() float64

func (P) Y

func (p P) Y() float64

type Tile

type Tile struct {
	X, Y         float64
	MovementCost float64
	Type         types.Type
	// contains filtered or unexported fields
}

func (*Tile) Copy

func (t *Tile) Copy(newtileset Tileset) *Tile

func (*Tile) Down

func (t *Tile) Down() *Tile

func (*Tile) Left

func (t *Tile) Left() *Tile

func (*Tile) ManhattanDistance

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

func (*Tile) PathEstimatedCost

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

func (*Tile) PathNeighborCost

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

func (*Tile) PathNeighbors

func (t *Tile) PathNeighbors() pathfinder.Pathers

func (*Tile) PathTo

func (t *Tile) PathTo(t2 *Tile) (pathfinder.Pathers, float64, bool)

func (*Tile) Pos

func (t *Tile) Pos() pixel.Vec

func (*Tile) Right

func (t *Tile) Right() *Tile

func (*Tile) SetTileset

func (t *Tile) SetTileset(newtileset Tileset)

func (*Tile) Up

func (t *Tile) Up() *Tile

type Tileset

type Tileset map[pixel.Vec]*Tile

type World

type World struct {
	// contains filtered or unexported fields
}

World for entities to live in

func New

func New() *World

New Empty World

func (*World) Batch

func (w *World) Batch(b Beings)

Batch update Beings

func (*World) BatchFn

func (w *World) BatchFn(fn func(b Being) error) error

func (*World) DealDamage

func (w *World) DealDamage(fromPlayer uint64, toPlayer uint64, amount float64) (healthAfter float64)

Update Being

func (*World) Get

func (w *World) Get(uid uint64) Being

func (*World) GetTile

func (w *World) GetTile(at pixel.Vec) *Tile

func (*World) Len

func (w *World) Len() int

func (*World) NewTile

func (w *World) NewTile(tiletype types.Type, x, y float64) *Tile

func (*World) Remove

func (w *World) Remove(playerid uint64)

Update Being

func (*World) SetTile

func (w *World) SetTile(t *Tile)

func (*World) SnapshotBeings

func (w *World) SnapshotBeings() Beings

func (*World) Update

func (w *World) Update(b Being) (isNew bool)

Update Being

Jump to

Keyboard shortcuts

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