namespace

This commit is contained in:
Mylloon 2024-01-06 15:54:21 +01:00
parent 91e3d1c349
commit 445bc5bbae
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -3,7 +3,9 @@
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
sf::RenderWindow Ecran::window; using namespace sf;
RenderWindow Ecran::window;
std::string Ecran::message = ""; std::string Ecran::message = "";
@ -18,8 +20,8 @@ Ecran::Ecran(const uint w, const uint h, const std::string n, const bool pf) {
++count; ++count;
// Création de la fenêtre SFML // Création de la fenêtre SFML
window.create(sf::VideoMode(w, h + bottomTxtPadding), n, window.create(VideoMode(w, h + bottomTxtPadding), n,
sf::Style::Titlebar | sf::Style::Close); Style::Titlebar | Style::Close);
fps = pf; fps = pf;
} }
@ -31,29 +33,29 @@ Ecran::~Ecran() {
void Ecran::afficher( void Ecran::afficher(
const std::function<void()> dessin, const std::function<void()> dessin,
const std::function<void(const int, const int)> onLeftClick) const { const std::function<void(const int, const int)> onLeftClick) const {
sf::Font font; Font font;
font.loadFromFile("assets/open-sans-latin-400-normal.ttf"); font.loadFromFile("assets/open-sans-latin-400-normal.ttf");
sf::Text text; Text text;
text.setFont(font); text.setFont(font);
text.setCharacterSize(24); text.setCharacterSize(24);
text.setPosition(3, hauteur()); text.setPosition(3, hauteur());
text.setFillColor(sf::Color::White); text.setFillColor(Color::White);
sf::Clock fpsClock; Clock fpsClock;
sf::Clock printFpsclock; Clock printFpsclock;
while (window.isOpen()) { while (window.isOpen()) {
sf::Event event; Event event;
while (window.pollEvent(event)) { while (window.pollEvent(event)) {
// Fermeture de la fenêtre // Fermeture de la fenêtre
if (event.type == sf::Event::Closed) { if (event.type == Event::Closed) {
window.close(); window.close();
} }
// Récupération des coordonnées du clic de souris // Récupération des coordonnées du clic de souris
if (event.type == sf::Event::MouseButtonPressed && if (event.type == Event::MouseButtonPressed &&
event.mouseButton.button == sf::Mouse::Left) { event.mouseButton.button == Mouse::Left) {
onLeftClick(event.mouseButton.x, event.mouseButton.y); onLeftClick(event.mouseButton.x, event.mouseButton.y);
} }
} }