Utilisation de pointeurs natifs plutôt qu'intelligents
This commit is contained in:
parent
773a703c76
commit
0dc46b5e7c
|
@ -69,7 +69,7 @@ Engine::Engine() {
|
|||
void Engine::update(State state) {
|
||||
// demande la mise à jour de tous les objets du jeu
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
objects[i]->update(state, delta);
|
||||
objects[i]->update(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,7 @@ void Engine::draw() {
|
|||
window.clear(sf::Color(66, 165, 245));
|
||||
|
||||
// chargement de la file d'affichage des objets
|
||||
typedef std::unique_ptr<Object> ObjectPtr;
|
||||
std::priority_queue<ObjectPtr, std::vector<ObjectPtr>, CompareObjectLayer> display_queue;
|
||||
std::priority_queue<Object*, std::vector<Object*>, CompareObjectLayer> display_queue;
|
||||
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
display_queue.push(objects[i]);
|
||||
|
@ -89,6 +88,7 @@ void Engine::draw() {
|
|||
unsigned int layer = 0;
|
||||
|
||||
while (!display_queue.empty()) {
|
||||
display_queue.pop()->draw(window);
|
||||
display_queue.top()->draw(window);
|
||||
display_queue.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define PTF_ENGINE_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "state.hpp"
|
||||
#include "object.hpp"
|
||||
|
@ -19,7 +18,7 @@ private:
|
|||
bool goLeftKey;
|
||||
bool goRightKey;
|
||||
|
||||
std::vector<std::unique_ptr<Object>> objects;
|
||||
std::vector<Object*> objects;
|
||||
|
||||
public:
|
||||
Engine();
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
* qui doit être dessinée avant celle du second
|
||||
*/
|
||||
struct CompareObjectLayer {
|
||||
bool operator()(Object const &obj1, Object const &obj2) {
|
||||
return obj1.getLayer() < obj2.getLayer();
|
||||
bool operator()(Object* const &obj1, Object* const &obj2) {
|
||||
return obj1->getLayer() < obj2->getLayer();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue