Utilisation de références plutôt que pointeurs
This commit is contained in:
parent
41216eb5e9
commit
6a53994312
|
@ -41,7 +41,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Ajoute un nouvel objet à la liste des objets du jeu
|
* Ajoute un nouvel objet à la liste des objets du jeu
|
||||||
*/
|
*/
|
||||||
void addObject(Object* object);
|
void addObject(Object& object);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,8 +51,8 @@ void Engine::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::addObject(Object* object) {
|
void Engine::addObject(Object& object) {
|
||||||
objects.push_back(object);
|
objects.push_back(&object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::update() {
|
void Engine::update() {
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -19,13 +19,13 @@ int main() {
|
||||||
ball2.setCharge(-2);
|
ball2.setCharge(-2);
|
||||||
block3.setCharge(10);
|
block3.setCharge(10);
|
||||||
|
|
||||||
engine.addObject(&ball1);
|
engine.addObject(ball1);
|
||||||
engine.addObject(&ball2);
|
engine.addObject(ball2);
|
||||||
engine.addObject(&block1);
|
engine.addObject(block1);
|
||||||
engine.addObject(&block2);
|
engine.addObject(block2);
|
||||||
engine.addObject(&block3);
|
engine.addObject(block3);
|
||||||
engine.addObject(&block4);
|
engine.addObject(block4);
|
||||||
engine.addObject(&block5);
|
engine.addObject(block5);
|
||||||
|
|
||||||
engine.start();
|
engine.start();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue