Documentation ¶
Index ¶
- func Angle(a, b Vec) float64
- type Circle
- type CircleCollider
- type ColliderCache
- type CollisionLayer
- type HashPosition
- type Rect
- func (r Rect) Center() Vec2
- func (r Rect) Contains(pos Vec) bool
- func (r *Rect) CutBottom(amount float64) Rect
- func (r *Rect) CutLeft(amount float64) Rect
- func (r *Rect) CutRight(amount float64) Rect
- func (r *Rect) CutTop(amount float64) Rect
- func (r Rect) H() float64
- func (r Rect) Intersects(r2 Rect) bool
- func (r Rect) Moved(v Vec2) Rect
- func (r Rect) Norm() Rect
- func (r Rect) Pad(pad Rect) Rect
- func (r Rect) Unpad(pad Rect) Rect
- func (r Rect) W() float64
- func (r Rect) WithCenter(v Vec2) Rect
- type Rigidbody
- type Rotation
- type Scale
- type SpatialBucket
- type SpatialHash
- type Vec
- type Vec2
- func (v Vec2) Add(v2 Vec2) Vec2
- func (t *Vec2) DecodeCod(bs []byte) (int, error)
- func (v Vec2) Dist(u Vec2) float64
- func (v Vec2) DistSq(u Vec2) float64
- func (v Vec2) Dot(u Vec2) float64
- func (t Vec2) EncodeCod(bs []byte) []byte
- func (v Vec2) Len() float64
- func (v Vec2) LenSq() float64
- func (v Vec2) Norm() Vec2
- func (v Vec2) Rotated(radians float64) Vec2
- func (v Vec2) Scaled(s float64) Vec2
- func (v Vec2) Sub(v2 Vec2) Vec2
- type Vel
- func (v Vel) Add(v2 Vel) Vel
- func (v Vel) Angle() float64
- func (t *Vel) DecodeCod(bs []byte) (int, error)
- func (v Vel) Dot(u Vel) float64
- func (t Vel) EncodeCod(bs []byte) []byte
- func (v Vel) Len() float64
- func (v Vel) Norm() Vel
- func (v Vel) Rotated(radians float64) Vel
- func (v Vel) Scaled(s float64) Vel
- func (v Vel) Sub(v2 Vel) Vel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Circle ¶
-------------------------------------------------------------------------------- - Circle --------------------------------------------------------------------------------
type CircleCollider ¶
type CircleCollider struct {
CenterX, CenterY float64 // TODO - right now this holds the entire position of the circle (relative to world space). You might consider stripping that out though
Radius float64
HitLayer CollisionLayer
Layer CollisionLayer
}
func NewCircleCollider ¶
func NewCircleCollider(radius float64) CircleCollider
func (*CircleCollider) Bounds ¶
func (c *CircleCollider) Bounds() Rect
func (*CircleCollider) Contains ¶
func (c *CircleCollider) Contains(yProjection float64, pos Vec) bool
func (*CircleCollider) LayerMask ¶
func (c *CircleCollider) LayerMask(layer CollisionLayer) bool
func (*CircleCollider) Overlaps ¶
func (c *CircleCollider) Overlaps(yProjection float64, c2 *CircleCollider) bool
type ColliderCache ¶
type ColliderCache struct { Current []ecs.Id Last []ecs.Id NewCollisions []ecs.Id // This list contains all new collisions }
This tracks the list of current collisions
func NewColliderCache ¶
func NewColliderCache() ColliderCache
func (*ColliderCache) Add ¶
func (c *ColliderCache) Add(id ecs.Id)
func (*ColliderCache) Clear ¶
func (c *ColliderCache) Clear()
type CollisionLayer ¶
type CollisionLayer uint8
func (CollisionLayer) Mask ¶
func (c CollisionLayer) Mask(layer CollisionLayer) bool
type HashPosition ¶
type HashPosition struct {
X, Y int32
}
type Rect ¶
type Rect struct {
Min, Max Vec
}
-------------------------------------------------------------------------------- - Rect --------------------------------------------------------------------------------
func (Rect) Intersects ¶
func (Rect) WithCenter ¶
type SpatialBucket ¶
type SpatialBucket struct {
// contains filtered or unexported fields
}
func NewSpatialBucket ¶
func NewSpatialBucket(hashPos HashPosition) *SpatialBucket
type SpatialHash ¶
type SpatialHash struct {
// contains filtered or unexported fields
}
This holds a spatial hash of objects placed inside
func NewSpatialHash ¶
func NewSpatialHash(bucketSize float64) *SpatialHash
TODO - pass in world dimensions? TODO - 2d bucket sizes?
func (*SpatialHash) AddCircle ¶
func (s *SpatialHash) AddCircle(id ecs.Id, circle *CircleCollider)
func (*SpatialHash) ToHashPosition ¶
func (s *SpatialHash) ToHashPosition(x, y float64) HashPosition
type Vec2 ¶
type Vec2 struct {
X, Y float64
}
Click to show internal directories.
Click to hide internal directories.