Jagguar Game Engine

Loading...
Searching...
No Matches
RigidbodyComponent.hpp
1#ifndef RIGIDBODYCOMPONENT_HPP
2#define RIGIDBODYCOMPONENT_HPP
3
4#include "IPhysicsComponent.hpp"
5#include "TransformComponent.hpp"
6#include "TinyMath.hpp"
7#include <string>
8
13 class RigidbodyComponent : public IPhysicsComponent {
14 public:
25 RigidbodyComponent(TransformComponent* pos, Vec2D dim, Vec2D vel, float m,
26 bool elastic = false, bool grav = false);
30 ~RigidbodyComponent();
31
32 void ApplyForce(Vec2D force) override;
33
34 void ApplyAcceleration(Vec2D acceleration) override;
35
36 void ApplyVelocity() override;
37
42 void Update(SDL_Event e, int frame, std::vector<std::string> broadcastList) override;
43
44 void ShowComponentEditor(bool* showEditor) override;
45
46 const char* ComponentTypeName() override {return "Rigidbody Component";}
47
48 // SETTERS
49
50 void SetVelocity(Vec2D vel) override;
51
52 // GETTERS
53
57 bool IsKinematic() override;
58
59 bool IsElastic() override;
60 bool UsesGravity() override;
61 Vec2D GetVelocity() override;
62 float GetMass() override;
63
64 private:
65 Vec2D velocity;
66 float mass;
67 bool isElastic;
68 bool usesGravity;
69};
70
71#endif
IPhysicsComponent
Definition: IPhysicsComponent.hpp:11
RigidbodyComponent
Definition: RigidbodyComponent.hpp:13
RigidbodyComponent::ApplyForce
void ApplyForce(Vec2D force) override
Definition: RigidbodyComponent.cpp:16
RigidbodyComponent::ShowComponentEditor
void ShowComponentEditor(bool *showEditor) override
Definition: RigidbodyComponent.cpp:35
RigidbodyComponent::ComponentTypeName
const char * ComponentTypeName() override
Definition: RigidbodyComponent.hpp:46
RigidbodyComponent::SetVelocity
void SetVelocity(Vec2D vel) override
Definition: RigidbodyComponent.cpp:50
RigidbodyComponent::IsKinematic
bool IsKinematic() override
Definition: RigidbodyComponent.cpp:56
RigidbodyComponent::ApplyVelocity
void ApplyVelocity() override
Definition: RigidbodyComponent.cpp:26
RigidbodyComponent::GetMass
float GetMass() override
Definition: RigidbodyComponent.cpp:60
RigidbodyComponent::UsesGravity
bool UsesGravity() override
Definition: RigidbodyComponent.cpp:58
RigidbodyComponent::GetVelocity
Vec2D GetVelocity() override
Definition: RigidbodyComponent.cpp:59
RigidbodyComponent::IsElastic
bool IsElastic() override
Definition: RigidbodyComponent.cpp:57
RigidbodyComponent::ApplyAcceleration
void ApplyAcceleration(Vec2D acceleration) override
Definition: RigidbodyComponent.cpp:22
RigidbodyComponent::Update
void Update(SDL_Event e, int frame, std::vector< std::string > broadcastList) override
Definition: RigidbodyComponent.cpp:30
RigidbodyComponent::~RigidbodyComponent
~RigidbodyComponent()
Definition: RigidbodyComponent.cpp:12
TransformComponent
Definition: TransformComponent.hpp:12
Vec2D
Definition: TinyMath.hpp:14