-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene.cpp
44 lines (39 loc) · 919 Bytes
/
scene.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
#include "scene.hpp"
Scene::Scene()
{
length = objectsList.size();
}
Scene::Scene(const vector<GameObject*> _objectsList)
{
if(_objectsList.size() > 0){
objectsList = _objectsList;
}
length = objectsList.size();
}
void Scene::add(GameObject* obj)
{
objectsList.push_back(obj);
}
void Scene::del(std::string name)
{
vector<GameObject*>::iterator toRemove;
for(vector<GameObject*>::iterator it = objectsList.begin(); it != objectsList.end(); ++it)
{
if((*it)->getName() == name)
{
toRemove = it;
break;
}
}
objectsList.erase(toRemove, toRemove + 1);
}
void Scene::draw(SDL_Surface* surface)
{
/*for(int i=0; i<length; i++){
objectsList.at(i).draw(surface);
}*/
for(vector<GameObject*>::iterator it = objectsList.begin(); it != objectsList.end(); ++it)
{
(*it)->draw(surface);
}
}