Physics object class. More...
#include <PhysicsObject.h>
Public Member Functions | |
PhysicsObject () | |
PhysicsObject (CIwFVec2 position, float gravityScale, float radius, float mass) | |
~PhysicsObject () | |
CIwFVec2 | GetPosition () |
void | SetPosition (CIwFVec2 position) |
void | Update (double deltaTime) |
float | GetRadius () |
float | GetGravityScale () |
float | GetMass () |
CIwFVec2 | GetVelocity () |
void | SetVelocity (CIwFVec2 newVelocity) |
void | SetGravityScale (float scale) |
int | GetNumCollisions () |
void | IncrementNumCollisions () |
float | GetBounciness () |
float | GetBottom () |
void | SetRadius (float radius) |
CIwFVec2 | GetNextPosition (double deltaTime) |
Protected Attributes | |
CIwFVec2 | m_position |
Position of the centre of the physics object. | |
CIwFVec2 | m_velocity |
Velocity of the physics object. | |
CIwFVec2 | m_gravity |
Force of gravity that will affect this physics object. | |
CIwFVec2 | m_acceleration |
Current acceleration of the physics object. | |
float | m_gravityScale |
Gravity scale for the physics object. | |
float | m_radius |
Radius of the physics object. | |
float | m_mass |
Mass of the physics object. | |
int | m_numCollisions |
How many times has this physics object collided with the grid? | |
float | m_bounciness |
How bouncy is this physics object? |
Physics object class.
A circular physics for discs and the top of the grid. Will fall under gravity and act like a projectile if Update() is called.
PhysicsObject::PhysicsObject | ( | ) | [inline] |
Default constructor.
Create a new physics object.
PhysicsObject::PhysicsObject | ( | CIwFVec2 | position, | |
float | gravityScale, | |||
float | radius, | |||
float | mass | |||
) |
Constructor.
Create a new physics object at a given position with attributes.
[in] | position | Position of the centre of the physicsObject. |
[in] | gravityScale | Scale for how much gravity will affect this physicsObject. |
[in] | radius | Radius of this physics object. |
[in] | mass | Mass of this physics object. |
PhysicsObject::~PhysicsObject | ( | ) |
Destructor.
Destroy the physics object and release all associated memory.
float PhysicsObject::GetBottom | ( | ) |
Get bottom.
Get the y position of the bottom of the physics object.
float PhysicsObject::GetBounciness | ( | ) |
Get bounciness.
Get how bouncy this physics object is. Affects collision response.
float PhysicsObject::GetGravityScale | ( | ) |
Get gravity scale.
Get the gravity scale of the physics object.
float PhysicsObject::GetMass | ( | ) |
Get mass.
Get the mass of the physics object.
CIwFVec2 PhysicsObject::GetNextPosition | ( | double | deltaTime | ) |
Get next position.
Get the position of the centre of the physics object at the next update. Should be used to prevent collision tunnelling.
[in] | deltaTime | Time since the last update. |
int PhysicsObject::GetNumCollisions | ( | ) |
Get collision count.
Get the number of times this physics object has collided with the grid.
CIwFVec2 PhysicsObject::GetPosition | ( | ) |
Get position.
Get the centre position of the physics object.
float PhysicsObject::GetRadius | ( | ) |
Get radius.
Get the radius of the physics object.
CIwFVec2 PhysicsObject::GetVelocity | ( | ) |
Get velocity.
Get the current velocity of the physics object.
void PhysicsObject::IncrementNumCollisions | ( | ) |
Increment collision count.
Increase the number of times this physics object has collided with the grid by one.
void PhysicsObject::SetGravityScale | ( | float | scale | ) |
Set gravity scale.
Set the gravity scale of the physics object.
[in] | scale | New gravity scale of the physics object (x,y). |
void PhysicsObject::SetPosition | ( | CIwFVec2 | position | ) |
Set position.
Set the centre position of the physics object.
[in] | position | The new position. |
void PhysicsObject::SetRadius | ( | float | radius | ) |
Set radius.
Set the radius of the physics object.
[in] | radius | New radius. |
void PhysicsObject::SetVelocity | ( | CIwFVec2 | newVelocity | ) |
Set velocity.
Set the velocity of the physics object.
[in] | newVelocity | New velocity of the physics object (x,y). |
void PhysicsObject::Update | ( | double | deltaTime | ) |
Update.
Update the disc.
[in] | deltaTime | Time since the last update. |