Utilisation de pointeurs natifs plutôt qu'intelligents

This commit is contained in:
Mattéo Delabre 2016-03-08 22:50:42 +01:00
parent 773a703c76
commit 0dc46b5e7c
3 changed files with 7 additions and 8 deletions

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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();
}
};