-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
33 lines (28 loc) · 869 Bytes
/
Entity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <string>
#include <functional>
#include "Entity.h"
#include "Player.h"
Entity::Entity(std::string nameOfEntity, std::function<void(Player &player, std::string &displayText)> onCollideFunction)
{
name = nameOfEntity;
onCollide = onCollideFunction;
eventHandler = [&](SDL_Event &e, Player &player) {};
}
Entity::Entity(std::string nameOfEntity, std::function<void(Player &player, std::string &displayText)> onCollideFunction, std::function<void(SDL_Event &e, Player &player)> eventHandlerFunction)
{
name = nameOfEntity;
onCollide = onCollideFunction;
eventHandler = eventHandlerFunction;
}
std::string Entity::getName()
{
return name;
}
void Entity::collided(Player &player, std::string &displayText)
{
onCollide(player, displayText);
}
void Entity::handleEvent(SDL_Event &e, Player &player)
{
eventHandler(e, player);
}