Building Game Engines
CollisionComponent.hpp
Go to the documentation of this file.
1 #ifndef COLLISION_COMPONENT_HPP
2 #define COLLISION_COMPONENT_HPP
3 
4 #include "Component.hpp"
5 #include "TransformComponent.hpp"
6 #include "TileMap.hpp"
7 
11 class CollisionComponent : public Component {
12  public:
18  CollisionComponent(TransformComponent* transform, TileMap* tilemap);
19 
24 
28  void UpdateCollisions();
29 
34  void Update();
35 
39  void Render(SDL_Renderer* renderer);
40 
41  private:
45  TransformComponent* transform;
46 
50  TileMap* tilemap = NULL;
51 
58  bool collide(SDL_Rect tile);
59 
63  double check_top(SDL_Rect tile, double posx, double posy, int width, int height);
67  double check_bottom(SDL_Rect tile, double posx, double posy, int width, int height);
71  double check_left(SDL_Rect tile, double posx, double posy, int width, int height);
75  double check_right(SDL_Rect tile, double posx, double posy, int width, int height);
76 };
77 
78 #endif
CollisionComponent(TransformComponent *transform, TileMap *tilemap)
Definition: CollisionComponent.cpp:6
Definition: TransformComponent.hpp:9
~CollisionComponent()
Definition: CollisionComponent.cpp:15
void Render(SDL_Renderer *renderer)
Definition: CollisionComponent.cpp:19
Definition: Component.hpp:10
Definition: CollisionComponent.hpp:11
void UpdateCollisions()
Definition: CollisionComponent.cpp:21
Definition: TileMap.hpp:14
void Update()
Definition: CollisionComponent.cpp:17