Calcul de l'état dans la fonction update

This commit is contained in:
Mattéo Delabre 2016-03-09 19:21:38 +01:00
parent 91c72fb9d7
commit ebd1cc15d6
2 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#include "engine.hpp"
#include "state.hpp"
#include <cmath>
#include <queue>
@ -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);

View File

@ -3,7 +3,6 @@
#include <vector>
#include <SFML/Graphics.hpp>
#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