-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityChild.cpp
75 lines (62 loc) · 1.49 KB
/
EntityChild.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "EntityChild.hpp"
#include "Display.hpp"
#include "Game.hpp"
#include "Logger.hpp"
EntityChild::EntityChild(void) {
return;
}
EntityChild::EntityChild(Entity *parent, char drawingChar, int rPosX, int rPosY)
: Entity(parent->GetPosX(), parent->GetPosY(), drawingChar, 0, parent->GetAlly()), _rPosX(rPosX), _rPosY(rPosY), _parent(parent)
{
this->_parent->AddChild(this);
}
EntityChild::EntityChild(int posX, int posY, char drawingChar, int speed, bool _ally, int rPosX, int rPosY)
: Entity(posX, posY, drawingChar, speed, _ally), _rPosX(rPosX), _rPosY(rPosY)
{
}
EntityChild::EntityChild(EntityChild const &src) {
*this = src;
return;
}
EntityChild::~EntityChild(void) {
return;
}
void EntityChild::SetParent(Entity *entity)
{
this->_parent = entity;
}
EntityChild &EntityChild::operator=(EntityChild const &rhs) {
if (this != &rhs) {
}
return *this;
}
void EntityChild::Update()
{
// if (this->_hasPosChanged)
// {
Display::Erase(this->_oldX, this->_oldY);
Display::PutChar(this->_drawingChar, this->_posX, this->_posY);
// this->_hasPosChanged = false;
// }
}
void EntityChild::Colision(Entity *entity)
{
this->_parent->Colision(entity);
}
Entity *EntityChild::GetParent()
{
return this->_parent;
}
bool EntityChild::UpdatePos(int x, int y)
{
x += this->_rPosX;
y += this->_rPosY;
if (!Display::IsInMap(x, y))
return false;
this->_hasPosChanged = true;
this->_oldX = this->_posX;
this->_oldY = this->_posY;
this->_posX = x;
this->_posY = y;
return true;
}