Documentation ¶
Index ¶
Constants ¶
const ( DrawableBody = iota DrawableJoint )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyOptions ¶ added in v0.2.0
type BodyOptions struct { StaticBody bool Position vect.Vect Angle vect.Float Mass vect.Float Velocity vect.Vect Elasticity vect.Float Friction vect.Float Type chipmunk.ShapeType CircleOptions CircleOptions BoxOptions BoxOptions }
BodyOptions holds the physical attributes for the Object
type BoxOptions ¶ added in v0.2.0
BoxOptions holds the attributes for a Box object
type CircleOptions ¶ added in v0.2.0
type CircleOptions struct {
Radius float32
}
CircleOptions holds the attributes for a Circle object
type CustomDrawFunc ¶
CustomDrawFunc is the callback function to provide additional functionality when drawing an Option. This is called after the main shape is drawn.
type Drawable ¶
type Drawable interface { Draw(imd *imdraw.IMDraw) GetOptions() DrawableOptions GetType() DrawableType GetBody() *chipmunk.Body GetJoint() *chipmunk.PivotJoint }
Drawable interface for any drawable Object
type DrawableOptions ¶ added in v0.2.0
type DrawableOptions struct { Color color.Color Thickness float64 CustomDrawFunc []CustomDrawFunc BodyOptions BodyOptions JointOptions JointOptions }
DrawableOptions for a drawable
type DrawableType ¶ added in v0.2.0
type DrawableType int
DrawableType indicates the subtype of the drawable
type Joint ¶ added in v0.2.0
type Joint struct {
// contains filtered or unexported fields
}
Joint joins two bodies together
func NewJointWithAnchor ¶ added in v0.2.0
func NewJointWithAnchor(object1, object2 *Object, offset1, offset2 vect.Vect, options DrawableOptions) *Joint
NewJointWithAnchor creates a constraint between two bodies at specified positions
func (Joint) GetJoint ¶ added in v0.2.0
func (j Joint) GetJoint() *chipmunk.PivotJoint
GetJoint returns the chipmunk.PivotJoint that the Object represents
func (Joint) GetOptions ¶ added in v0.2.0
func (j Joint) GetOptions() DrawableOptions
GetOptions returns the DrawableOptions that were used to create the Object
func (Joint) GetType ¶ added in v0.2.0
func (j Joint) GetType() DrawableType
GetType returns the type of drawable
type JointOptions ¶ added in v0.2.0
type JointOptions struct {
Draw bool
}
JointOptions contains options for drawing joints
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents an object inside the World
func NewBox ¶
func NewBox(options DrawableOptions) *Object
NewBox creates a new Object for a rectangle
func NewCircle ¶
func NewCircle(options DrawableOptions) *Object
NewCircle creates a new Object that represents a circle / disc / ball
func NewObject ¶
func NewObject(body *chipmunk.Body, options DrawableOptions) *Object
NewObject creates a new Object for the provided Body and DrawableOptions
func NewObjectWithShape ¶
func NewObjectWithShape(shape *chipmunk.Shape, options DrawableOptions) *Object
NewObjectWithShape creates a new Object for the provided Shape and DrawableOptions
func (Object) GetJoint ¶ added in v0.2.0
func (o Object) GetJoint() *chipmunk.PivotJoint
GetJoint returns the chipmunk.PivotJoint that the Object represents
func (Object) GetOptions ¶
func (o Object) GetOptions() DrawableOptions
GetOptions returns the DrawableOptions that were used to create the Object
func (Object) GetType ¶ added in v0.2.0
func (o Object) GetType() DrawableType
GetType returns the type of drawable
type World ¶
type World struct { Name string Bounds pixel.Rect FrameRate int Space *chipmunk.Space RunFunc func(*opengl.Window) RunCallback func(*opengl.Window) Objects []Drawable }
World represents the world that chipmunk will simulate