-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
116 lines (92 loc) · 2.01 KB
/
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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "Entity.h"
Entity::Entity(void)
{
position = glm::vec2();
}
Entity::~Entity(void)
{
for(int i = 0; i < shapes.size(); i++)
{
delete shapes[i];
}
}
//------------------------------------------------SET ----------------------------------------------//
void Entity::setPosition(glm::vec2 positionIn)
{
position = positionIn;
}
void Entity::setPosition(float x, float y)
{
position.x = x;
position.y = y;
}
void Entity::setRotation(float rotationIn)
{
rotation = rotationIn;
}
//------------------------------------------------GET ----------------------------------------------//
glm::vec2 Entity::getPosition(void)
{
return position;
}
float Entity::getRotation(void)
{
return rotation;
}
std::vector<Shape*> Entity::getShapes(void)
{
return shapes;
}
std::vector<Entity*> Entity::getChildren(void)
{
return children;
}
//------------------------------------------------ADD ----------------------------------------------//
void Entity::addShape(Shape* shapeIn)
{
shapes.push_back(shapeIn);
}
void Entity::addChild(Entity* childIn)
{
children.push_back(childIn);
}
void Entity::insertShapeAt(int indexIn, Shape* shapeIn)
{
shapes.insert(shapes.begin()+indexIn, shapeIn);
}
void Entity::insertChildAt(int indexIn, Entity* childIn)
{
children.insert(children.begin()+indexIn, childIn);
}
//------------------------------------------------REMOVE -------------------------------------------//
void Entity::removeShapes(void)
{
while(!shapes.empty())
{
delete shapes.back();
shapes.pop_back();
}
}
void Entity::removeChildren(void)
{
while(!children.empty())
{
delete children.back();
children.pop_back();
}
}
void Entity::removeShapeAt(int indexIn)
{
delete shapes.at(indexIn);
shapes.erase(shapes.begin()+indexIn);
}
void Entity::removeChildAt(int indexIn)
{
delete children.at(indexIn);
children.erase(children.begin()+indexIn);
}
//------------------------------------------------RELEASE-------------------------------------------//
void Entity::releaseChildren(void)
{
children.clear();
}