Documentation ¶
Overview ¶
Package entities stores common, useful object and entity combinations.
Index ¶
- type Doodad
- type Interactive
- type Moving
- type Point
- type Reactive
- func (r *Reactive) Destroy()
- func (r *Reactive) GetLogicDim() (float64, float64)
- func (r *Reactive) GetReactiveSpace() *collision.ReactiveSpace
- func (r *Reactive) GetSpace() *collision.Space
- func (r *Reactive) Init() event.CID
- func (r *Reactive) SetDim(w, h float64)
- func (r *Reactive) SetLogicDim(w, h float64)
- func (r *Reactive) SetPos(x, y float64)
- func (r *Reactive) SetSpace(sp *collision.ReactiveSpace)
- func (r *Reactive) ShiftPos(x, y float64)
- type Solid
- func (s *Solid) Destroy()
- func (s *Solid) GetLogicDim() (float64, float64)
- func (s *Solid) GetSpace() *collision.Space
- func (s *Solid) HitLabel(classtype collision.Label) *collision.Space
- func (s *Solid) Init() event.CID
- func (s *Solid) SetDim(w, h float64)
- func (s *Solid) SetLogicDim(w, h float64)
- func (s *Solid) SetPos(x float64, y float64)
- func (s *Solid) SetSpace(sp *collision.Space)
- func (s *Solid) ShiftPos(x, y float64)
- func (s *Solid) ShiftSpace(x, y float64)
- func (s *Solid) ShiftX(x float64)
- func (s *Solid) ShiftY(y float64)
- func (s *Solid) UpdateLabel(classtype collision.Label)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doodad ¶
type Doodad struct { Point event.CID R render.Renderable }
A Doodad is an entity composed of a position, a renderable, and a CallerID.
func NewDoodad ¶
NewDoodad returns a new doodad that is not drawn but is initialized. Passing a CID of 0 will initialize the entity as a Doodad. Passing any other CID will assume that the struct containing this doodad has already been initialized to the passed in CID. This applies to ALL NewX functions in entities which take in a CID.
func (*Doodad) Destroy ¶
func (d *Doodad) Destroy()
Destroy cleans up the events, renderable and entity mapping for this Doodad
func (*Doodad) GetRenderable ¶
func (d *Doodad) GetRenderable() render.Renderable
GetRenderable returns this Doodad's Renderable
func (*Doodad) SetPos ¶
SetPos both Sets logical position and renderable position The need for this sort of function is lessened with the introduction of vector attachement.
func (*Doodad) SetRenderable ¶
func (d *Doodad) SetRenderable(r render.Renderable)
SetRenderable sets this Doodad's renderable, drawing it. Todo:this automatic drawing doesn't really work with our two tiers of draw layers
type Interactive ¶
type Interactive struct { Reactive // contains filtered or unexported fields }
Interactive parallels Moving, but for Reactive instead of Solid
func NewInteractive ¶
func NewInteractive(x, y, w, h float64, r render.Renderable, tree *collision.Tree, cid event.CID, friction float64) *Interactive
NewInteractive returns a new Interactive
func (*Interactive) ApplyFriction ¶
func (v *Interactive) ApplyFriction(outsideFriction float64)
ApplyFriction modifies a moving's delta by combining environmental friction with the moving's base friction and scaling down the delta by the combined result.
type Moving ¶
type Moving struct { Solid // contains filtered or unexported fields }
A Moving is a Solid that also keeps track of a speed and a delta vector
func NewMoving ¶
func NewMoving(x, y, w, h float64, r render.Renderable, tree *collision.Tree, cid event.CID, friction float64) *Moving
NewMoving returns a new Moving
func (*Moving) ApplyFriction ¶
func (v *Moving) ApplyFriction(outsideFriction float64)
ApplyFriction modifies a moving's delta by combining environmental friction with the moving's base friction and scaling down the delta by the combined result.
func (*Moving) ShiftVector ¶
ShiftVector probably shouldn't be on moving but it lets you ShiftPos by a given vector
type Point ¶
A Point is a wrapper around a physics vector.
func (*Point) DistanceTo ¶
DistanceTo returns the euclidean distance to (x,y)
func (*Point) DistanceToPoint ¶
DistanceToPoint returns the euclidean distance to p2.GetLogicPos()
func (*Point) GetLogicPos ¶
GetLogicPos returns the logical position of an entity. See SetLogicPos.
func (*Point) SetLogicPos ¶
SetLogicPos is an explicit declaration for setting just the logical position of an entity. On a Point there is no distinction as there is nothing but the logical position but this is important for other entity types
func (*Point) ShiftLogicPos ¶
ShiftLogicPos shifts a point's underlying position by both x and y
type Reactive ¶
Reactive is parallel to Solid, but has a Reactive collision space instead of a regular collision space
func NewReactive ¶
func NewReactive(x, y, w, h float64, r render.Renderable, tree *collision.Tree, cid event.CID) *Reactive
NewReactive returns a new Reactive struct. The added space will be added to the input tree, or DefTree if none is given.
func (*Reactive) Destroy ¶
func (r *Reactive) Destroy()
Destroy destroys this reactive's doodad component and removes its space from it's collision tree
func (*Reactive) GetLogicDim ¶
GetLogicDim returns this Reactive's width and height todo: move wh into their own struct to compose into solid and reactive
func (*Reactive) GetReactiveSpace ¶
func (r *Reactive) GetReactiveSpace() *collision.ReactiveSpace
GetReactiveSpace returns this reactive's RSpace
func (*Reactive) SetDim ¶
SetDim sets the dimensions of this reactive's space and it's logical dimensions
func (*Reactive) SetLogicDim ¶
SetLogicDim sets the logical width and height of this reactive without changing the real dimensions of its collision space
func (*Reactive) SetPos ¶
SetPos sets this reactive's logical, renderable, and collision position to be x,y
func (*Reactive) SetSpace ¶
func (r *Reactive) SetSpace(sp *collision.ReactiveSpace)
SetSpace sets this reactive's collision space to the given reactive space, updating it's collision tree to include it.
type Solid ¶
A Solid is a Doodad with a width, height, and collision space.
func NewSolid ¶
NewSolid returns an initialized Solid that is not drawn and whose space belongs to the given collision tree. If nil is given as the tree, it will belong to collision.DefTree
func (*Solid) Destroy ¶
func (s *Solid) Destroy()
Destroy removes this solid's collision space from it's Tree and destroys the doodad portion of the solid.
func (*Solid) GetLogicDim ¶
GetLogicDim will return the width and height of the Solid
func (*Solid) HitLabel ¶
HitLabel will return the first space that this solid collides with matching the given label that it finds, or nil if it finds nothing.
func (*Solid) SetDim ¶
SetDim sets the logical dimensions of the solid and the real dimensions on the solid's space
func (*Solid) SetLogicDim ¶
SetLogicDim sets the width and height of the solid
func (*Solid) SetPos ¶
SetPos sets the position of the collision space, the logical position, and the renderable position of the solid.
func (*Solid) SetSpace ¶
SetSpace assigns a solid a collision space and puts it in this Solid's Tree
func (*Solid) ShiftSpace ¶
ShiftSpace will shift this solid's collision space by (x,y)
func (*Solid) UpdateLabel ¶
UpdateLabel will update it's label in this solid's collision tree.