Class: PhysicsEngine

Physics.PhysicsEngine

the physics engine of JSCF.

new Physics.PhysicsEngine (entities)

Name Type Description
entities Container container of entities (usually dictionary)

Members

gravity Utils.Vector2d

gravity acceleration in px/s^2 (default: (0, 9.8 * pixelMeterRatio) )

numIterations Number

number of iterations/ticks per update (default: 7)

pixelMeterRatio Number

pixels/meter ratio (default: 50)

simSpeed Number

simulation speed multiplier

tickDuration Number

tick duration in seconds. Should be linear to 1/numIterations! (default: Scene.tick_duration/numIterations)

Methods

applyCollision (manifold)

resolve a collision described by a manifold
Name Type Description
manifold Physics.Manifold collision manifold of two entities.

applyNaturalForces (rigidbody)

applys natural forces to a rigidbody component
Name Type Description
rigidbody Components.Rigidbody rigidbody component

detectCollisions ()Array

detects collisions
Returns:
Type Description
Array array of collision manifolds

fixPenetration (manifold)

fixes penetration/energy loss
Name Type Description
manifold Physics.Manifold collision manifold

resolveCollisions (manifolds)

resolve collision manifolds
Name Type Description
manifolds Array array of collision manifolds

resolveNaturalForces ()

resolve natural forces on engine's tracked entities.

update (tick_duration)

updates physics engine (tick)
Name Type Description
tick_duration Number the time (in seconds) of a tick (usually dt)