Game Engine 2D Platformer
PhysicsComponent.hpp
Go to the documentation of this file.
1 /*
2  * @file PhysicsComponent.hpp
3  * @brief PhysicsComponent class interface
4  * @date 2021-03-12
5  ***********************************************/
6 #ifndef PHYSICSCOMPONENT_HPP
7 #define PHYSICSCOMPONENT_HPP
8 
9 #include "Component.hpp"
13 {
14  top,
19 };
20 
24 {
25 public:
35  void StartUp();
38  void ShutDown();
42  void Update(GameEntity &entity);
43 
44 private:
50  collisionType GetCollisionDirection(GameEntity& entity, GameEntity& otherEntity);
56  void ResolveCollision(collisionType collision, GameEntity& entity, GameEntity& otherEntity);
62  bool CheckCollisions(GameEntity& entity, GameEntity& otherEntity);
67  void HandleCoinCollisions(GameEntity& entity, std::vector<std::shared_ptr<GameEntity>> coins);
72  void HandleNPCCollisions(GameEntity& entity, std::vector<std::shared_ptr<GameEntity>> npcs);
77  void HandleEndFlagCollisions(GameEntity &entity, std::vector<std::shared_ptr<GameEntity>> endFlags);
78  int xRenderOffset{0};
79  int yRenderOffset{0};
80 };
81 
82 #endif
collisionType
Enum of type of Collisions i.e. Top, Bottom and etc.
Definition: PhysicsComponent.hpp:13
@ noCollision
Definition: PhysicsComponent.hpp:18
@ top
Definition: PhysicsComponent.hpp:14
@ bottom
Definition: PhysicsComponent.hpp:16
@ left
Definition: PhysicsComponent.hpp:15
@ right
Definition: PhysicsComponent.hpp:17
The interface class for different components to inherit.
Definition: Component.hpp:16
Represents an interactable entity in the game that includes Main Character, NPC, Tiles ,...
Definition: GameEntity.hpp:22
PhysicsComponent class used manage a GameEntity's movement.
Definition: PhysicsComponent.hpp:24
void Update(GameEntity &entity)
Updates the PhysicsComponent.
Definition: PhysicsComponent.cpp:22
void ShutDown()
Destroys and frees attributes for PhysicsComponent.
Definition: PhysicsComponent.cpp:15
void StartUp()
Initializes the attributes for PhysicsComponent.
Definition: PhysicsComponent.cpp:11
~PhysicsComponent()
Destructor for PhysicsComponent.
Definition: PhysicsComponent.cpp:7
PhysicsComponent()
Constuctor for PhysicsComponent.
Definition: PhysicsComponent.cpp:3