Package com.deco2800.game.physics
Class PhysicsEngine
java.lang.Object
com.deco2800.game.physics.PhysicsEngine
- All Implemented Interfaces:
 com.badlogic.gdx.utils.Disposable
Process game physics using the Box2D library. See the Box2D documentation for examples or use
 cases.
- 
Constructor Summary
ConstructorsConstructorDescriptionPhysicsEngine(com.badlogic.gdx.physics.box2d.World world, GameTime timeSource)  - 
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.physics.box2d.BodycreateBody(com.badlogic.gdx.physics.box2d.BodyDef bodyDef) com.badlogic.gdx.physics.box2d.JointcreateJoint(com.badlogic.gdx.physics.box2d.JointDef jointDef) voiddestroyBody(com.badlogic.gdx.physics.box2d.Body body) voiddestroyJoint(com.badlogic.gdx.physics.box2d.Joint joint) voiddispose()com.badlogic.gdx.physics.box2d.WorldgetWorld()booleanraycast(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, short layerMask, RaycastHit hit) Cast a ray in a straight line from one point to another, checking for a collision against colliders in the specified layers.booleanraycast(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, RaycastHit hit) Cast a ray in a straight line from one point to another, checking for a collision against any colliders.raycastAll(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to) Cast a ray in a straight line from one point to another, checking for all collision against colliders in the specified layers.raycastAll(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, short layerMask) Cast a ray in a straight line from one point to another, checking for all collision against colliders in the specified layers.voidupdate() 
- 
Constructor Details
- 
PhysicsEngine
public PhysicsEngine() - 
PhysicsEngine
 
 - 
 - 
Method Details
- 
update
public void update() - 
createBody
public com.badlogic.gdx.physics.box2d.Body createBody(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)  - 
destroyBody
public void destroyBody(com.badlogic.gdx.physics.box2d.Body body)  - 
createJoint
public com.badlogic.gdx.physics.box2d.Joint createJoint(com.badlogic.gdx.physics.box2d.JointDef jointDef)  - 
destroyJoint
public void destroyJoint(com.badlogic.gdx.physics.box2d.Joint joint)  - 
getWorld
public com.badlogic.gdx.physics.box2d.World getWorld() - 
raycast
public boolean raycast(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, RaycastHit hit) Cast a ray in a straight line from one point to another, checking for a collision against any colliders.- Parameters:
 from- The starting point of the ray.to- The end point of the ray.hit- The raycast result will be stored in this class- Returns:
 - true if a collider was hit, false otherwise.
 
 - 
raycast
public boolean raycast(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, short layerMask, RaycastHit hit) Cast a ray in a straight line from one point to another, checking for a collision against colliders in the specified layers.- Parameters:
 from- The starting point of the ray.to- The end point of the ray.hit- The hit of the closest collider will be stored in this.layerMask- The physics layer mask which specifies layers that can be hit. Other layers will be ignored.- Returns:
 - true if a collider was hit, false otherwise.
 
 - 
raycastAll
public RaycastHit[] raycastAll(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to) Cast a ray in a straight line from one point to another, checking for all collision against colliders in the specified layers.- Parameters:
 from- The starting point of the ray.to- The end point of the ray.- Returns:
 - All hits made by the ray, unordered. Empty if no hits were made.
 
 - 
raycastAll
public RaycastHit[] raycastAll(com.badlogic.gdx.math.Vector2 from, com.badlogic.gdx.math.Vector2 to, short layerMask) Cast a ray in a straight line from one point to another, checking for all collision against colliders in the specified layers.- Parameters:
 from- The starting point of the ray.to- The end point of the ray.layerMask- The physics layer mask which specifies layers that can be hit. Other layers will be ignored.- Returns:
 - All hits made by the ray, unordered. Empty if no hits were made.
 
 - 
dispose
public void dispose()- Specified by:
 disposein interfacecom.badlogic.gdx.utils.Disposable
 
 -