-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainer.cpp
More file actions
64 lines (55 loc) · 907 Bytes
/
Copy pathContainer.cpp
File metadata and controls
64 lines (55 loc) · 907 Bytes
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
#include "Container.h"
Container::Container(void)
{
setX(0);
setY(0);
}
Container::Container(int x, int y)
{
setX(x);
setY(y);
}
void Container::draw(int x, int y)
{
vector<DrawableSDL *>::iterator it = cont.begin();
while(it != cont.end())
{
(*it)->draw(this->x + x, this->y + y);
it++;
}
}
void Container::remove(DrawableSDL* element)
{
vector<DrawableSDL *>::iterator it = cont.begin();
while(it != cont.cend())
{
if((*it) == element)
{
cont.erase(it);
return;
}
it++;
}
}
void Container::add(DrawableSDL* drawing)
{
drawing->parent = this;
cont.push_back(drawing);
}
Container::~Container(void)
{
return;
vector<DrawableSDL *>::iterator it = cont.begin();
while(cont.size() > 0)
{
cont.erase(it);
it++;
}
}
bool Container::spreadEvent(SDL_Event e)
{
for(int i = cont.size()-1; i>=0; i--)
if(cont[i]->spreadEvent(e))
return true;
return false;
}