Box.round( Float v ) ⇢ Integer
Rounds the given float to a integer, this function is intended for rendering purposes and tries to reduce jitter.
- Float v
Box.World( Vec2 gravity = Vec2(0.0, 50.0)
, Integer steps = 10
, Integer iterations = 10
)
-
Vec2 gravity ⬞ The gravity applied to all bodies contained by the world.
-
Integer steps ⬞ Number of simulation steps to perform on each world update.
-
Integer iterations ⬞ Number of iterations to perform for each collision contact.
- Double EPSILON ⬞ Value used as a threshold for friction and resting of bodies.
-
Integer contactCount ⬞ Number of contacts between the two bodies in the manifold.
-
Manifold[] contacts ⬞ List of contacts manifold that resulted from the last world update.
-
Vec2 gravity ⬞ The gravity applied to all bodies contained by the world.
-
addBody( Body body ) ⇢ Boolean
Adds a body to the world.
- Body body ⬞ Body to add.
-
containsBody( Body body ) ⇢ Boolean
Checks whether a body is part of the world.
- Body body ⬞ Body.
-
removeBody( Body body ) ⇢ Boolean
Removes a body from the world.
- Body body ⬞ Body to remove.
-
update( Double dt )
Advances the simulation by the given number of seconds.
- Double dt ⬞ Seconds.
Box.AABB( Vec2 position, Vec2 extend, Double mass = 0.0
, Double inertia = 0.0
) extends Body
-
Vec2 position ⬞ Initial position of the AABB.
-
Vec2 extend ⬞ Extends of the AABB, the AABB will extend from its center in all directions based on the components of the vector.
-
Double mass ⬞ Mass of the AABB.
-
Double inertia ⬞ Inertia of the AABB.
- Integer ShapeID ⬞ Unique ID identifying the collision shape.
-
Vec2 extend ⬞ Extends of the object, each half.
-
computeMass( Double density )
Computes the mass and inertia of the AABB based on its area and the given density.
- Double density
Box.Circle( Vec2 position, Double radius, Double mass = 0.0
, Double inertia = 0.0
) extends Body
-
Vec2 position ⬞ Initial position of the Circle.
-
Double radius ⬞ Radius of the Cirlce.
-
Double mass ⬞ Mass of the Circle.
-
Double inertia ⬞ Inertia of the Circle.
- Integer ShapeID ⬞ Unique ID identifying the collision shape.
-
Double radius ⬞ Radius of the circle.
-
computeMass( Double density )
Computes the mass and inertia of the circle based on its radius and the given density.
- Double density
Box.Vec2( Double x, Double y )
-
Double x ⬞ x component of the vector.
-
Double y ⬞ y component of the vector.
-
Returns the result of the adding the second vector.
- Vec2 v ⬞ Vector to be added.
-
angle( ) ⇢ Double
Returns the direction in which the vector is pointing in radians.
-
Calculates the dot product between the two vectors.
- Vec2 v ⬞ The second vector.
-
Divides the vector in-place.
- Double s ⬞ Scalar.
-
Calculates the dot product of the two vectors.
- Vec2 v ⬞ The second vector.
-
length( ) ⇢ Double
Returns the length of the vector by using the square root of its length.
-
lengthSqr( ) ⇢ Double
Returns the length of the vector by simply squaring its components.
-
Multiplies the vector in-place.
- Double s ⬞ Scalar.
-
normalize( ) ⇢ Vec2
Returns a unit vector with length 1.
-
Returns a the result of the substraction of the second vector.
- Vec2 v ⬞ Vector to be subtracted.
-
zero( )
Sets both components of the vector to 0.
Body( Integer shapeId, Vec2 position, Double mass = 0.0
, Double inertia = 0.0
)
-
Integer shapeId ⬞ Unique ID used identifying the bodies type.
-
Vec2 position ⬞ Initial position of the body.
-
Double mass ⬞ Mass of the body.
-
Double inertia ⬞ Inertia of the body.
- Integer id ⬞ Unique ID counter identifying each {Body}.
-
Double angularVelocity ⬞ Angular velocity in radians.
-
Double iI ⬞ Inverse inertia of the body. A value of 0 specifies infinite inertia.
-
Integer id ⬞ Unique ID of this body.
-
Double im ⬞ Inverse mass of the body. A value of 0 specifies infinite mass.
-
Double kineticFriction ⬞ Friction when the body is in motion.
-
Double orientation ⬞ Orientation in radians.
-
Vec2 pixelPosition ⬞ Position, rounded to the nearest full pixel value.
-
Vec2 position ⬞ Position.
-
Double restitution ⬞ "Bounciness" of the object's surface.
-
Double staticFriction ⬞ Friction when the body is at rest.
-
Double torque ⬞ Torque in radians.
-
Any user ⬞ Reference to custom user data attached to the body.
-
Vec2 velocity ⬞ Velocity of the body.
-
applyImpulse( Vec2 velocity, Vec2 angularVelocity )
Applies the specified impulse to the body.