Mise en place de la caméra (qui ne suit pas encore la balle)
This commit is contained in:
parent
81924e6fdb
commit
9ef5b6683d
|
@ -14,6 +14,7 @@ private:
|
||||||
sf::Clock clock;
|
sf::Clock clock;
|
||||||
sf::RenderWindow window;
|
sf::RenderWindow window;
|
||||||
EngineState state;
|
EngineState state;
|
||||||
|
sf::View view;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Met à jour les objets du jeu pour
|
* Met à jour les objets du jeu pour
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
#include "constants.hpp"
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
Engine::Engine() : window(
|
Engine::Engine() : window(
|
||||||
sf::VideoMode(704, 480), "Projet CMI",
|
sf::VideoMode(800, 600), "Projet CMI",
|
||||||
sf::Style::Default & ~sf::Style::Resize,
|
sf::Style::Default & ~sf::Style::Resize,
|
||||||
sf::ContextSettings(0, 0, 2)
|
sf::ContextSettings(0, 0, 2)
|
||||||
) {
|
), view(sf::FloatRect(200, 200, 300, 200)){
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
|
//mise en place de la caméra
|
||||||
|
view.setSize(800, 600);
|
||||||
|
window.setView(view);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::start() {
|
void Engine::start() {
|
||||||
float accumulator = 0;
|
|
||||||
|
|
||||||
// boucle d'événements sur la fenêtre
|
// boucle d'événements sur la fenêtre
|
||||||
while (window.isOpen()) {
|
while (window.isOpen()) {
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
|
@ -35,16 +38,9 @@ void Engine::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float frame = clock.restart().asSeconds();
|
state.delta = 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();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue