diff --git a/include/engine.hpp b/include/engine.hpp index 1ed0e7f..815d346 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -14,7 +14,7 @@ private: sf::Clock clock; sf::RenderWindow window; EngineState state; - sf::View view; + sf::View view; /** * Met à jour les objets du jeu pour diff --git a/src/engine.cpp b/src/engine.cpp index 181c484..a855675 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -3,17 +3,15 @@ #include Engine::Engine() : window( - sf::VideoMode(800, 600), "Projet CMI", + sf::VideoMode(704, 480), "Projet CMI", sf::Style::Default & ~sf::Style::Resize, sf::ContextSettings(0, 0, 2) ), view(sf::FloatRect(200, 200, 300, 200)){ window.setVerticalSyncEnabled(true); - //mise en place de la caméra - view.setSize(800, 600); - window.setView(view); - - + // mise en place de la caméra + view.setSize(800, 600); + window.setView(view); } void Engine::start() { @@ -38,9 +36,16 @@ void Engine::start() { } } - state.delta = clock.restart().asSeconds(); + float frame = clock.restart().asSeconds(); + accumulator += frame; + + // tant qu'il reste du temps à passer, + // effectuer la simulation physique étape par étape + while (accumulator >= Constants::PHYSICS_TIME) { + accumulator -= Constants::PHYSICS_TIME; + update(); + } - update(); draw(); } }