diff --git a/engine.cpp b/engine.cpp index f76befd..17f2ab0 100644 --- a/engine.cpp +++ b/engine.cpp @@ -1,4 +1,5 @@ #include "engine.hpp" +#include "state.hpp" #include #include @@ -53,20 +54,20 @@ Engine::Engine() { } } - // réinitialise l'horloge à zéro et calcule la différence - // puis établit l'objet stockant l'état du moteur - State state; - state.delta = clock.restart().asSeconds(); - state.goLeftKey = goLeftKey; - state.goRightKey = goRightKey; - state.objects = objects; - - update(state); + update(); draw(); } } -void Engine::update(State state) { +void Engine::update() { + // calcul du temps écoulé depuis la dernière frame + // et création de l'objet state stockant l'état du moteur + State state; + state.delta = clock.restart().asSeconds(); + state.goLeftKey = goLeftKey; + state.goRightKey = goRightKey; + state.objects = objects; + // demande la mise à jour de tous les objets du jeu for (int i = 0; i < objects.size(); i++) { objects[i]->update(state); diff --git a/engine.hpp b/engine.hpp index eaae37b..b7a80a2 100644 --- a/engine.hpp +++ b/engine.hpp @@ -3,7 +3,6 @@ #include #include -#include "state.hpp" #include "object.hpp" /** @@ -32,7 +31,7 @@ public: * Met à jour les objets du jeu pour * qu'ils s'adaptent au nouvel état du moteur */ - void update(State state); + void update(); }; #endif