Documentation ¶
Overview ¶
Package entities stores useful object and entity types, such as positions and renderables, collision spaces and renderables, and delta / speed vectors built into the above types.
A number of the functions used by the types in entities assume that legacy behavior is being used.
Index ¶
- type Doodad
- type Interactive
- type Moving
- type Point
- type Reactive
- func (r *Reactive) Destroy()
- func (r *Reactive) GetLogicDim() (float64, float64)
- 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)
- func (r *Reactive) String() string
- type Solid
- func (s *Solid) Destroy()
- func (s *Solid) GetLogicDim() (float64, float64)
- func (s *Solid) GetSpace() *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) ShiftX(x float64)
- func (s *Solid) ShiftY(y float64)
- func (s *Solid) String() string
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, cid event.CID, friction float64) Interactive
NewInteractive returns a new Interactive
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 (*Moving) ApplyFriction ¶
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
type Reactive ¶
type Reactive struct { Doodad W, H float64 RSpace *collision.ReactiveSpace }
Reactive is parallel to Solid, but has a Reactive collision space instead of a regular collision space
func NewReactive ¶
NewReactive returns a new reactive
func (*Reactive) Destroy ¶
func (r *Reactive) Destroy()
Destroy destroys this reactive's doodad component and removes its space from the default collision tree (todo: legacy, fix this)
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) 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 the default collision tree to include it. Todo: fix that
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 no collision tree
func (*Solid) Destroy ¶
func (s *Solid) Destroy()
Destroy removes this solid's collision space from the default tree (todo) and destroys the doodad portion of the solid.
func (*Solid) GetLogicDim ¶
GetLogicDim will return the width and height of the Solid
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.