Documentation ¶
Overview ¶
Package coord implements math primitives that are used in a 2d cell/tile based game.
Index ¶
- Constants
- Variables
- type Bounds
- func (b Bounds) Area() int
- func (b Bounds) BotL() Cell
- func (b Bounds) Contains(c Cell) bool
- func (a Bounds) DiffFrom(b Bounds) []Bounds
- func (b Bounds) Expand(mag int) Bounds
- func (b Bounds) HasOnEdge(c Cell) (onEdge bool)
- func (b Bounds) Height() int
- func (b Bounds) Intersection(other Bounds) (Bounds, error)
- func (b Bounds) Invert() Bounds
- func (b Bounds) IsInverted() bool
- func (b Bounds) Join(with Bounds) Bounds
- func (b Bounds) JoinAll(bounds ...Bounds) Bounds
- func (b Bounds) Overlaps(other Bounds) bool
- func (b Bounds) Quads() ([4]Bounds, error)
- func (b Bounds) TopR() Cell
- func (b Bounds) Width() int
- type Cell
- type CellCollision
- type Collision
- type CollisionType
- type Direction
- type MoveAction
- type PartialCell
- type PathAction
- func (pa PathAction) Bounds() Bounds
- func (pa *PathAction) CanHappenAfter(anAction MoveAction) bool
- func (A PathAction) CollidesWith(B interface{}) (c Collision)
- func (pa PathAction) Crosses(path PathAction) bool
- func (pa PathAction) DestPartial(now stime.Time) (pc PartialCell)
- func (pa PathAction) Direction() Direction
- func (pa *PathAction) End() stime.Time
- func (pa PathAction) IsParallelTo(pa2 PathAction) bool
- func (pa PathAction) OrigPartial(now stime.Time) (pc PartialCell)
- func (pa *PathAction) Start() stime.Time
- func (pa PathAction) String() string
- func (pa PathAction) ToState() PathActionState
- func (pa PathAction) Traverses(c Cell) bool
- func (pa PathAction) TraversesAt(c Cell, t stime.Time) (pc PartialCell, err error)
- type PathActionState
- type PathCollision
- type Quad
- type TurnAction
Constants ¶
View Source
const TurnActionDelay = 10
Currenting in Frames, optimized for 40fps TODO Conditionalize this with the fps
Variables ¶
View Source
var ErrBoundsAreInverted = errors.New("bounds are inverted")
View Source
var ErrBoundsAreTooSmall = errors.New("bounds are too small to split")
View Source
var ErrInvalidDirection = errors.New("invalid direction")
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
func JoinBounds ¶
func (Bounds) DiffFrom ¶
Diffs 2 overlapping bounds and returns a slice of rectangles that are contained within b and not contained within other. The slice of rectangles will either have 1,2,3,5,8 rectangles.
1 rect - Iff w && h are the same and it shares 2 parallel edges aka, its been translated in 1 of the 4 directions 2 rect - TODO Iff w || h are different but it shares 2 perpendicular edges 3 rect - TODO If w && h are different and it shares 2 perpendicular edges 3 rect - *TODO If w && h are the same, but it's been translated by 2 directions 5 rect - TODO Iff w && h are different and other shares 1 edge with b 8 rect - TODO Iff b contains other and shares no edges
type Cell ¶
func (Cell) DirectionTo ¶
type CellCollision ¶
type CellCollision struct { CollisionType stime.Span Cell Cell Path PathAction }
func NewCellCollision ¶
func NewCellCollision(p PathAction, c Cell) (cc CellCollision)
func (CellCollision) End ¶
func (c CellCollision) End() stime.Time
func (CellCollision) Start ¶
func (c CellCollision) Start() stime.Time
func (CellCollision) Type ¶
func (c CellCollision) Type() CollisionType
type CollisionType ¶
type CollisionType int
const ( CT_NONE CollisionType = iota CT_HEAD_TO_HEAD CT_FROM_SIDE CT_A_INTO_B CT_A_INTO_B_FROM_SIDE CT_SWAP CT_SAME_ORIG CT_SAME_ORIG_PERP CT_SAME_ORIG_DEST CT_CELL_DEST CT_CELL_ORIG )
TODO Implement this as bitflags
func (CollisionType) String ¶
func (i CollisionType) String() string
type Direction ¶
type Direction byte
func NewDirectionWithString ¶
Create a new direction from a string value. Returns ErrInvalidDirection if the string doesn't represent a valid direction.
func (Direction) IsParallelTo ¶
type MoveAction ¶
type PartialCell ¶
func (PartialCell) String ¶
func (p PartialCell) String() string
type PathAction ¶
func (PathAction) Bounds ¶
func (pa PathAction) Bounds() Bounds
func (*PathAction) CanHappenAfter ¶
func (pa *PathAction) CanHappenAfter(anAction MoveAction) bool
func (PathAction) CollidesWith ¶
func (A PathAction) CollidesWith(B interface{}) (c Collision)
func (PathAction) Crosses ¶
func (pa PathAction) Crosses(path PathAction) bool
func (PathAction) DestPartial ¶
func (pa PathAction) DestPartial(now stime.Time) (pc PartialCell)
func (PathAction) Direction ¶
func (pa PathAction) Direction() Direction
func (*PathAction) End ¶
func (pa *PathAction) End() stime.Time
func (PathAction) IsParallelTo ¶
func (pa PathAction) IsParallelTo(pa2 PathAction) bool
func (PathAction) OrigPartial ¶
func (pa PathAction) OrigPartial(now stime.Time) (pc PartialCell)
func (*PathAction) Start ¶
func (pa *PathAction) Start() stime.Time
func (PathAction) String ¶
func (pa PathAction) String() string
func (PathAction) ToState ¶
func (pa PathAction) ToState() PathActionState
func (PathAction) Traverses ¶
func (pa PathAction) Traverses(c Cell) bool
func (PathAction) TraversesAt ¶
func (pa PathAction) TraversesAt(c Cell, t stime.Time) (pc PartialCell, err error)
type PathActionState ¶
type PathCollision ¶
type PathCollision struct { CollisionType stime.Span A, B PathAction }
func NewPathCollision ¶
func NewPathCollision(a, b PathAction) (c PathCollision)
func (PathCollision) End ¶
func (c PathCollision) End() stime.Time
func (PathCollision) Start ¶
func (c PathCollision) Start() stime.Time
func (PathCollision) Type ¶
func (c PathCollision) Type() CollisionType
type TurnAction ¶
func (TurnAction) CanHappenAfter ¶
func (a TurnAction) CanHappenAfter(anAction MoveAction) bool
func (TurnAction) End ¶
func (a TurnAction) End() stime.Time
func (TurnAction) Start ¶
func (a TurnAction) Start() stime.Time
Click to show internal directories.
Click to hide internal directories.