Jagguar Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
IPhysicsComponent Class Reference

#include <IPhysicsComponent.hpp>

Inheritance diagram for IPhysicsComponent:
Inheritance graph
[legend]
Collaboration diagram for IPhysicsComponent:
Collaboration graph
[legend]

Public Member Functions

 IPhysicsComponent (TransformComponent *pos, Vec2D dim)
 
 ~IPhysicsComponent ()
 
bool IsColliding (IPhysicsComponent *other)
 
virtual void ApplyForce (Vec2D force)
 
virtual void ApplyAcceleration (Vec2D acceleration)
 
virtual void ApplyVelocity ()
 
virtual void SetVelocity (Vec2D vel)
 
virtual bool IsKinematic ()
 
virtual bool IsElastic ()
 
virtual bool UsesGravity ()
 
Vec2D GetPosition ()
 
Vec2D GetDimensions ()
 
virtual Vec2D GetVelocity ()
 
virtual float GetMass ()
 
- Public Member Functions inherited from Component
 Component ()
 
 ~Component ()
 
virtual void Update (SDL_Event e, int frame, std::vector< std::string > broadcastList)
 
virtual void Render (SDL_Renderer *ren)
 
virtual void ShowComponentEditor (bool *showEditor)
 
virtual bool HasTag (ComponentTag t)
 
virtual const char * ComponentTypeName ()
 
void ParseAndUpdateBroadcast (std::vector< std::string > broadcastList)
 

Protected Attributes

TransformComponentm_position
 
Vec2D dimensions
 
std::vector< ComponentTag > tags = {ComponentTag::Physics}
 
- Protected Attributes inherited from Component
std::vector< ComponentTag > tags
 
std::vector< std::string > previousBroadcasts
 
std::vector< std::string > pendingBroadcasts
 

Detailed Description

An interface for all components that will be interacting with the PhysicEngine

Constructor & Destructor Documentation

◆ IPhysicsComponent()

IPhysicsComponent::IPhysicsComponent ( TransformComponent pos,
Vec2D  dim 
)

Construct a new IPhysicsComponent object

Parameters
posthe position of the GameObject the Component is attached to
dimthe dimensions (width, height) of the GameObject the Component is attached to

◆ ~IPhysicsComponent()

IPhysicsComponent::~IPhysicsComponent ( )

Destroy the IPhysicsComponent object

Member Function Documentation

◆ ApplyAcceleration()

void IPhysicsComponent::ApplyAcceleration ( Vec2D  acceleration)
virtual

Change the velocity of the Component. Adds the acceleration value to the current velocity.

Reimplemented in RigidbodyComponent.

◆ ApplyForce()

void IPhysicsComponent::ApplyForce ( Vec2D  force)
virtual

Apply a force to the Component. Handles forces outside of collisions (such as from scripts).

Parameters
forcethe force to be applied to the IPhysicsComponent
See also
SetVelocity() to directly change the velocity
ApplyAcceleration() to modify the acceleration
ApplyVelocity() to finalize movement

Reimplemented in RigidbodyComponent.

◆ ApplyVelocity()

void IPhysicsComponent::ApplyVelocity ( )
virtual

Moves the Component. The IPhysicsComponent will not move until this is called.

See also
ApplyForce() to use force to change the velocity
SetVelocity() to directly change the velocity
ApplyAcceleration() to modify the acceleration

Reimplemented in RigidbodyComponent.

◆ GetDimensions()

Vec2D IPhysicsComponent::GetDimensions ( )

Get the dimensions of the IPhysicsComponent.

Returns
the dimensions of the Component
Here is the caller graph for this function:

◆ GetMass()

float IPhysicsComponent::GetMass ( )
virtual

Get the mass of the IPhysicsComponent.

Returns
the mass of the Component

Reimplemented in RigidbodyComponent.

Here is the caller graph for this function:

◆ GetPosition()

Vec2D IPhysicsComponent::GetPosition ( )

Get the position of the IPhysicsComponent.

Returns
the position of the Component
See also
TransformComponent
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVelocity()

Vec2D IPhysicsComponent::GetVelocity ( )
virtual

Get the velocity of the IPhysicsComponent.

Returns
the velocity of the Component

Reimplemented in RigidbodyComponent.

◆ IsColliding()

bool IPhysicsComponent::IsColliding ( IPhysicsComponent other)

Check for a collision with the given IPhysicsComponent.

Parameters
otherthe Component to check for collisions
Returns
whether other is colliding with this object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsElastic()

bool IPhysicsComponent::IsElastic ( )
virtual

Get whether the IPhysicsComponent bounces or just stops on collision.

Returns
whether the IPhysicsComponent uses elastic collisions
See also
PhysicsEngine::Update()

Reimplemented in RigidbodyComponent.

Here is the caller graph for this function:

◆ IsKinematic()

bool IPhysicsComponent::IsKinematic ( )
virtual

Get whether the IPhysicsComponent is kinematic. Allows for Colliders to only get collision data, without applying forces to other Components

Returns
whether the IPhysicsComponent uses kinematic collisions
See also
PhysicsEngine::Update()

Reimplemented in RigidbodyComponent.

Here is the caller graph for this function:

◆ SetVelocity()

void IPhysicsComponent::SetVelocity ( Vec2D  vel)
virtual

Set the velocity of the IPhysicsComponent.

Parameters
velthe new velocity

Reimplemented in RigidbodyComponent.

◆ UsesGravity()

bool IPhysicsComponent::UsesGravity ( )
virtual

Get whether the PhysicsEngine will apply gravity forces to the IPhysicsComponent.

Returns
whether the IPhysicsComponent uses gravity

Reimplemented in RigidbodyComponent.

Member Data Documentation

◆ dimensions

Vec2D IPhysicsComponent::dimensions
protected

pointer to the TransformComponent used by the shared parent GameObject


The documentation for this class was generated from the following files: