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