SDL Minigame  1.0
Loading...
Searching...
No Matches
CollisionHandler.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "ColliderComponent.h"
8#include "Constants.h"
9#include "Entity.h"
10#include "SDL_rect.h"
11#include "SpriteComponent.h"
12#include "Vector2D.h"
13#include "Manager.h"
14
15#include <bitset>
16#include <initializer_list>
17#include <tuple>
18#include <utility>
19#include <vector>
20
22class Entity;
23
24// [IntersectionBitSet]
25constexpr uint8_t DIRECTION_C = 4;
26
27using IntersectionBitSet = std::bitset<DIRECTION_C>;
28// [IntersectionBitSet]
29
31{
32private:
33 Manager& manager;
34
35public:
36
37 CollisionHandler(Manager& mManager) :
38 manager(mManager) { };
40
41 static IntersectionBitSet getIntersection( // intersections relative to entityA
42 Entity* entityA,
43 Entity* entityB,
44 Vector2D posModA = Vector2D(0,0),
45 Vector2D posModB = Vector2D(0,0));
46 static IntersectionBitSet getIntersectionWithBounds( // will fail to determine direction if speed high enough to switch from no collision to full overlap in one tick
47 Entity* entity,
48 Vector2D posMod = Vector2D(0,0));
49
50 // temporary function, remove once game.cpp cleaned up
51 std::vector<ColliderComponent*> getColliders(
52 std::initializer_list<Entity::GroupLabel> const& groupLabels,
53 std::initializer_list<Entity::TeamLabel> const& teamLabels = {},
54 bool negateTeam = false);
55
70 template<typename T>
72 Entity* entity,
73 Vector2D posMod = {},
74 std::initializer_list<Entity::GroupLabel> const& groupLabels = {},
75 std::initializer_list<Entity::TeamLabel> const& teamLabels = {},
76 bool negateTeam = false);
77
78 void update();
79};
Definition ColliderComponent.h:11
Definition CollisionHandler.h:31
T getAnyIntersection(Entity *entity, Vector2D posMod={}, std::initializer_list< Entity::GroupLabel > const &groupLabels={}, std::initializer_list< Entity::TeamLabel > const &teamLabels={}, bool negateTeam=false)
Tests entity against all entities with the specified labels for a collision.
Main class for any object in game, stores associations, labeling and components.
Definition Entity.h:29
Is responsible for managing all entities.
Definition Manager.h:20
Definition Vector2D.h:7