Rubeus::Awerere::ACollider class

A simple collider. Used to resolve collisions.

Derived classes

class ABoxCollider
A box collider attached to a Game object through a Physics object.
class APlaneCollider
A 2D plane collider, equivalent to a straight line on a 2D screen.
class ASphereCollider
A Sphere Collider for handling spherical collisions.

Constructors, destructors, conversion operators

ACollider(RML::Vector2D position = RML::Vector2D(0.0f, 0.0f))
Constructor.
ACollider(const RML::Vector2D& position, const RML::Vector2D& velocity, const APhysicsMaterial& physicsMat = APhysicsMaterial::DefaultMaterial, const int& zIndex = 0)
Constructor.
~ACollider() virtual
Destructor.

Public functions

auto tryIntersect(ACollider& collider) -> ACollideData
Generate collision status data object to see if object collides with another.
auto tryIntersect(ABoxCollider& box) -> ACollideData pure virtual
Query collision status with another box type collider.
auto tryIntersect(ASphereCollider& sphere) -> ACollideData pure virtual
Query collision status with another sphere type collider.
auto tryIntersect(APlaneCollider& plane) -> ACollideData pure virtual
Query collision status with another plane type collider.
void update(const float& deltaTime)
Update the collider member positions.
void selfUpdate(float deltaX, float deltaY) pure virtual
Update the collider position for members specific to a collider type.
void addImpulse(RML::Vector2D& impulse)
Add an impulse to this object.
auto getPosition() const -> RML::Vector2D
Returns the position of this collider.
auto getMomentum() const -> RML::Vector2D
Returns the momentum of this position.
auto getType() const -> EColliderType
Returns the type of this collider.
void setPosition(const RML::Vector2D& position)
Set the position of this collider.
void setMomentum(const RML::Vector2D& momentum)
Set the momentum of this collider.
void setMaterial(const APhysicsMaterial& physicsMat)
Set a custom physics material for this collider.
void addForce(RML::Vector2D& force)
Add a force on this collider.
void addMomentum(RML::Vector2D& momentum)
Add momentum to this collider.
void setZIndex(const unsigned int& zindex)
Sets z-index of collider.
auto getZIndex() -> unsigned int
Returns the z-index of this collider.

Public variables

RML::Vector2D m_Position
The central position of the collider.
RML::Vector2D m_Momentum
Momentum of the collider in 2D space.
RML::Vector2D m_Force
The force being applied on this collider.
APhysicsMaterial m_PhysicsMaterial
The physical constants describing the material of this collider.
EColliderType m_Type
Type of the collider.
GraphicComponents::RSprite* m_Sprite
The sprite linked to this collider.
unsigned int m_ZIndex
z-index of this collider

Function documentation

Rubeus::Awerere::ACollider::ACollider(const RML::Vector2D& position, const RML::Vector2D& velocity, const APhysicsMaterial& physicsMat = APhysicsMaterial::DefaultMaterial, const int& zIndex = 0)

Constructor.

Parameters
position The position of the collider.
velocity The velocity of the collider.
physicsMat The physics material of this collider. Default is DefualtMaterial
zIndex

ACollideData Rubeus::Awerere::ACollider::tryIntersect(ACollider& collider)

Generate collision status data object to see if object collides with another.

Parameters
collider The collider object to test against.
Returns A struct containing collision status data.

ACollideData Rubeus::Awerere::ACollider::tryIntersect(ABoxCollider& box) pure virtual

Query collision status with another box type collider.

Parameters
box The box collider this collider is being queried with.
Returns Collision data.

ACollideData Rubeus::Awerere::ACollider::tryIntersect(ASphereCollider& sphere) pure virtual

Query collision status with another sphere type collider.

Parameters
sphere The sphere collider this collider is being queried with.
Returns Collision data.

ACollideData Rubeus::Awerere::ACollider::tryIntersect(APlaneCollider& plane) pure virtual

Query collision status with another plane type collider.

Parameters
plane The plane collider this collider is being queried with.
Returns Collision data.

void Rubeus::Awerere::ACollider::update(const float& deltaTime)

Update the collider member positions.

Parameters
deltaTime Time step taken.

void Rubeus::Awerere::ACollider::selfUpdate(float deltaX, float deltaY) pure virtual

Update the collider position for members specific to a collider type.

Parameters
deltaX Change in X.
deltaY Change in Y.

void Rubeus::Awerere::ACollider::addImpulse(RML::Vector2D& impulse)

Add an impulse to this object.

Parameters
impulse The impulse to be applied.

RML::Vector2D Rubeus::Awerere::ACollider::getPosition() const

Returns the position of this collider.

Returns Position of this collider.

RML::Vector2D Rubeus::Awerere::ACollider::getMomentum() const

Returns the momentum of this position.

Returns Momentum of this collider.

EColliderType Rubeus::Awerere::ACollider::getType() const

Returns the type of this collider.

Returns Type of this collider.

void Rubeus::Awerere::ACollider::setPosition(const RML::Vector2D& position)

Set the position of this collider.

Parameters
position The newer position value.

void Rubeus::Awerere::ACollider::setMomentum(const RML::Vector2D& momentum)

Set the momentum of this collider.

Parameters
momentum The new momentum value.

void Rubeus::Awerere::ACollider::setMaterial(const APhysicsMaterial& physicsMat)

Set a custom physics material for this collider.

Parameters
physicsMat The physics material to be used.

void Rubeus::Awerere::ACollider::addForce(RML::Vector2D& force)

Add a force on this collider.

Parameters
force The force to be applied.

void Rubeus::Awerere::ACollider::addMomentum(RML::Vector2D& momentum)

Add momentum to this collider.

Parameters
momentum The momentum to be added.

void Rubeus::Awerere::ACollider::setZIndex(const unsigned int& zindex)

Sets z-index of collider.

Parameters
zindex z-index to be assigned.

unsigned int Rubeus::Awerere::ACollider::getZIndex()

Returns the z-index of this collider.

Returns z-index of this collider