Documentation ¶
Index ¶
- type Body
- func (b *Body) BoundsRect() gmath.Rect
- func (b *Body) CircleRadius() float64
- func (b *Body) Dispose()
- func (b *Body) InitCircle(o interface{}, radius float64)
- func (b *Body) InitRotatedRect(o interface{}, width, height float64)
- func (b *Body) InitStaticCircle(o interface{}, radius float64)
- func (b *Body) InitStaticRotatedRect(o interface{}, width, height float64)
- func (b *Body) IsCircle() bool
- func (b *Body) IsDisposed() bool
- func (b *Body) IsRotatedRect() bool
- func (b *Body) RotatedRectHeight() float64
- func (b *Body) RotatedRectVertices() RectVertices
- func (b *Body) RotatedRectWidth() float64
- func (b Body) String() string
- type Collision
- type CollisionConfig
- type CollisionEngine
- type RectVertices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body struct { Object interface{} Rotation gmath.Rad Pos gmath.Vec LayerMask uint16 // contains filtered or unexported fields }
func (*Body) BoundsRect ¶
func (*Body) CircleRadius ¶
func (*Body) InitCircle ¶
func (*Body) InitRotatedRect ¶
func (*Body) InitStaticCircle ¶
func (*Body) InitStaticRotatedRect ¶
func (*Body) IsDisposed ¶
func (*Body) IsRotatedRect ¶
func (*Body) RotatedRectHeight ¶
func (*Body) RotatedRectVertices ¶
func (b *Body) RotatedRectVertices() RectVertices
func (*Body) RotatedRectWidth ¶
type Collision ¶
type Collision struct { // Body is a body being collided. // To get a collision object, access `Collision.Body.Object`. Body *Body // LayerMask represents the layer masks intersection of the colliding objects. LayerMask uint16 // Normal is a contacted surface collision normal vector. // Collision normal vector has unit length (it's normalized). // // Note: a normal is computed only when resolving with non-zero velocity. Normal gmath.Vec Depth float64 }
type CollisionConfig ¶
type CollisionConfig struct { Offset gmath.Vec // If velocity magnitude is not 0, collisions are calculated // in the dynamics of the movement. Velocity gmath.Vec // If not 0, this mask will be used instead of the object own mask. // It can be used to both include or exclude some other objects from // the collisions calculation. LayerMask uint16 Limit int }
type CollisionEngine ¶
type CollisionEngine struct {
// contains filtered or unexported fields
}
func (*CollisionEngine) AddBody ¶
func (e *CollisionEngine) AddBody(b *Body)
AddBody includes the given body into the collision space.
Note that it will not be ready to register or cause any collisions until the next frame.
func (*CollisionEngine) CalculateFrame ¶
func (e *CollisionEngine) CalculateFrame()
CalculateFrame re-calculates layers and other things for the upcoming frame. This function is called from the framework itself in the beginning of each frame.
func (*CollisionEngine) GetCollisions ¶
func (e *CollisionEngine) GetCollisions(b *Body, config CollisionConfig) []Collision
GetCollisions returns all colliders for the specified body. A config can affect the rules of this collision computation.
type RectVertices ¶
func (*RectVertices) LL ¶
func (v *RectVertices) LL() gmath.Vec
func (*RectVertices) LR ¶
func (v *RectVertices) LR() gmath.Vec
func (*RectVertices) UL ¶
func (v *RectVertices) UL() gmath.Vec
func (*RectVertices) UR ¶
func (v *RectVertices) UR() gmath.Vec
Click to show internal directories.
Click to hide internal directories.