diff --git a/includes/Ecran.hpp b/includes/Ecran.hpp new file mode 100644 index 0000000..ad2b3da --- /dev/null +++ b/includes/Ecran.hpp @@ -0,0 +1,19 @@ +#ifndef PROJECT_ECRAN_HPP +#define PROJECT_ECRAN_HPP 1 + +#include +#include + +class Ecran { + // Fenêtre + sf::RenderWindow window; + +public: + Ecran(const uint width = 800, const uint height = 800, + const std::string name = "Projet"); // constructor + ~Ecran(); // destructor + + void afficher(std::function f = {[]() {}}); +}; + +#endif diff --git a/src/Ecran.cpp b/src/Ecran.cpp new file mode 100644 index 0000000..67806b9 --- /dev/null +++ b/src/Ecran.cpp @@ -0,0 +1,26 @@ +#include "../includes/Ecran.hpp" + +Ecran::Ecran(const uint w, const uint h, const std::string n) { + // Création de la fenêtre SFML + window.create(sf::VideoMode(w, h), n); +} + +Ecran::~Ecran() {} + +void Ecran::afficher(std::function dessin) { + while (window.isOpen()) { + sf::Event event; + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + } + } + + window.clear(); + + // Appel d'une fonction dessin + dessin(); + + window.display(); + } +}