Documentation ¶
Index ¶
- func Abs[T Number](n T) T
- func After(lock *bool, seconds float64, f func())
- func Clamp[T Number](n, low, high T) T
- func ClampIndexToMap[T Integer](index, mapWidth, mapHeight T) T
- func ClampXYToMap[T Integer](x, y, mapWidth, mapHeight T) (T, T)
- func Distance(x1, y1, x2, y2 float64) float64
- func DistanceManhattan[T Number](x1, y1, x2, y2 T) T
- func Every(seconds float64, f func()) context.CancelFunc
- func Filter[T any](s []T, f func(T) bool) []T
- func IndexToXY[T Integer](idx, mapWidth T) (x, y T)
- func IsIndexInRange[T Integer](index, mapWidth, mapHeight T) bool
- func IsXYInRange[T Integer](x, y, mapWidth, mapHeight T) bool
- func Lerp[T Number](start, end, t T) T
- func LerpEaseIn[T Number](start, end, t T) T
- func LerpEaseOut[T Number](start, end, t T) T
- func Magnitude[T Number](x, y T) T
- func Map[T any](s []T, f func(T) T) []T
- func MapTo[T, E any](s []T, f func(T) E) []E
- func MinOrZero[T Number](v, min T) T
- func Normalize[T Float](x, y T) (T, T)
- func Remove[T any](s []T, i int) []T
- func RemoveMany[T any](s []T, ii ...int) []T
- func Sqr[T Number](t T) T
- func TilesetRect[T Integer](sprite, tileSize, tilesetWidth T) (x1, y1, x2, y2 T)
- func XYRange[T Number](x1, y1, x2, y2 T) (T, T, T, T)
- func XYToIndex[T Integer](x, y, mapWidth T) T
- type AmmoContainer
- type Float
- type Integer
- type Mover
- type Number
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClampIndexToMap ¶
func ClampIndexToMap[T Integer](index, mapWidth, mapHeight T) T
Removes under/overflow.
func ClampXYToMap ¶
func ClampXYToMap[T Integer](x, y, mapWidth, mapHeight T) (T, T)
Removes under/overflow.
func DistanceManhattan ¶
func DistanceManhattan[T Number](x1, y1, x2, y2 T) T
func IndexToXY ¶
func IndexToXY[T Integer](idx, mapWidth T) (x, y T)
1D to 2D coordinate conversion.
func IsIndexInRange ¶
func IsXYInRange ¶
func LerpEaseIn ¶
func LerpEaseIn[T Number](start, end, t T) T
func LerpEaseOut ¶
func LerpEaseOut[T Number](start, end, t T) T
func RemoveMany ¶
Mutates in place, no allocations. Does not keep order.
func TilesetRect ¶
func TilesetRect[T Integer](sprite, tileSize, tilesetWidth T) (x1, y1, x2, y2 T)
1D index (sprite) to tileset rectangle. Assumes a square tileset.
sprite = 3, tileSize = N, tilesetWidth = 4 . . x x . . . x x . . . . . . . . . . .
Types ¶
type AmmoContainer ¶
type AmmoContainer[T comparable] map[T]uint
func (AmmoContainer[T]) CurrentAmmo ¶
func (a AmmoContainer[T]) CurrentAmmo(t T) uint
func (AmmoContainer[T]) Take ¶
func (a AmmoContainer[T]) Take(t T, hasAlready, capacity uint) uint
type Float ¶
type Float interface { constraints.Float }
type Integer ¶
type Integer interface { constraints.Signed | constraints.Unsigned }
type Mover ¶
type Mover[T Float] struct { PosX T PosY T DeltaX T DeltaY T MinimumVelocity T Acceleration T Drag T }
Normalized, lerped movement with drag.
func (*Mover[T]) AddMovement ¶
func (m *Mover[T]) AddMovement(x, y T)
func (*Mover[T]) UpdateDelta ¶
func (m *Mover[T]) UpdateDelta(delta T)
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
Click to show internal directories.
Click to hide internal directories.