Public Member Functions | Protected Attributes

PhysicsObject Class Reference

Physics object class. More...

#include <PhysicsObject.h>

List of all members.

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?

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
[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.


Member Function Documentation

float PhysicsObject::GetBottom (  ) 

Get bottom.

Get the y position of the bottom of the physics object.

Returns:
float position.
float PhysicsObject::GetBounciness (  ) 

Get bounciness.

Get how bouncy this physics object is. Affects collision response.

Returns:
float bounciness.
float PhysicsObject::GetGravityScale (  ) 

Get gravity scale.

Get the gravity scale of the physics object.

Returns:
float gravity scale of the physics object.
float PhysicsObject::GetMass (  ) 

Get mass.

Get the mass of the physics object.

Returns:
float 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.

Parameters:
[in] deltaTime Time since the last update.
Returns:
Vector2 position.
int PhysicsObject::GetNumCollisions (  ) 

Get collision count.

Get the number of times this physics object has collided with the grid.

Returns:
int number of collisions.
CIwFVec2 PhysicsObject::GetPosition (  ) 

Get position.

Get the centre position of the physics object.

Returns:
Vector2 position.
float PhysicsObject::GetRadius (  ) 

Get radius.

Get the radius of the physics object.

Returns:
float radius of the physics object.
CIwFVec2 PhysicsObject::GetVelocity (  ) 

Get velocity.

Get the current velocity of the physics object.

Returns:
Vector2 velocity of the physics object (x,y).
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.

Parameters:
[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.

Parameters:
[in] position The new position.
void PhysicsObject::SetRadius ( float  radius  ) 

Set radius.

Set the radius of the physics object.

Parameters:
[in] radius New radius.
void PhysicsObject::SetVelocity ( CIwFVec2  newVelocity  ) 

Set velocity.

Set the velocity of the physics object.

Parameters:
[in] newVelocity New velocity of the physics object (x,y).
void PhysicsObject::Update ( double  deltaTime  ) 

Update.

Update the disc.

Parameters:
[in] deltaTime Time since the last update.

The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations