From 9ef5b6683d97e66f5854c6a53b60c67479cc0fe3 Mon Sep 17 00:00:00 2001 From: maelle Date: Sun, 20 Mar 2016 13:18:20 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20en=20place=20de=20la=20cam=C3=A9ra=20(qu?= =?UTF-8?q?i=20ne=20suit=20pas=20encore=20la=20balle)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/engine.hpp | 1 + src/engine.cpp | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/engine.hpp b/include/engine.hpp index 47efd34..1ed0e7f 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -14,6 +14,7 @@ private: sf::Clock clock; sf::RenderWindow window; EngineState state; + sf::View view; /** * Met à jour les objets du jeu pour diff --git a/src/engine.cpp b/src/engine.cpp index f391d00..181c484 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -1,19 +1,22 @@ #include "engine.hpp" -#include "constants.hpp" #include #include Engine::Engine() : window( - sf::VideoMode(704, 480), "Projet CMI", + sf::VideoMode(800, 600), "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); + + } void Engine::start() { - float accumulator = 0; - // boucle d'événements sur la fenêtre while (window.isOpen()) { sf::Event event; @@ -35,16 +38,9 @@ void Engine::start() { } } - 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(); - } + state.delta = clock.restart().asSeconds(); + update(); draw(); } }