diff --git a/include/draw.hpp b/include/draw.hpp index c65e5a0..de03f7d 100644 --- a/include/draw.hpp +++ b/include/draw.hpp @@ -27,5 +27,8 @@ void drawMiniCarte(int x, int y, Color color, RenderWindow *window, int largeur, void drawText(int x, int y, string text, RenderWindow *window, int size, Color color, string fontPath); + +void draw(RenderWindow &window); -#endif /* DRAW_HPP*/ \ No newline at end of file + +#endif /* DRAW_HPP*/ diff --git a/include/jeu.hpp b/include/jeu.hpp index 21b6181..dac27eb 100644 --- a/include/jeu.hpp +++ b/include/jeu.hpp @@ -33,9 +33,10 @@ class Jeu { InventoryRenderer m_invRender; Coord m_mousePosCam; Coord m_mousePosWorld; + Texture texture; public: - Jeu(Texture &texture); + Jeu(); void run(); diff --git a/src/jeu.cpp b/src/jeu.cpp index a50a4d9..fecb9c5 100644 --- a/src/jeu.cpp +++ b/src/jeu.cpp @@ -3,15 +3,21 @@ using namespace std; using namespace sf; -Jeu::Jeu(sf::Texture &texture) +Jeu::Jeu() : m_window(VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), TITRE_FENETRE), - m_char(0, 0, - texture), // Passer la texture (spritesheet) - m_posCam(0, 0), m_inv("../assets/csv/inventory.csv"), m_mousePosCam(0, 0), - m_invRender(m_inv) { - m_map = Map(); + m_char(0, 0, texture), + m_posCam(0, 0), + m_inv("../assets/csv/inventory.csv"), + m_mousePosCam(0, 0), + m_invRender(m_inv) +{ + if (!texture.loadFromFile("../assets/img/personnage.png")) { + cout << "Erreur de chargement de la spritesheet." << endl; + } + m_map = Map(); } + void Jeu::run() { Clock clock; Time timePerFrame = seconds(1.f / FPS_MAX); @@ -191,12 +197,7 @@ void Jeu::save() { m_inv.save("../assets/csv/inventory.csv"); } int main(int arg, char **argv) { - Texture spritesheet; - if (!spritesheet.loadFromFile("../assets/img/personnage.png")) { - cout << "Erreur de chargement de la spritesheet." << endl; - } - - Jeu jeu(spritesheet); + Jeu jeu; jeu.run(); return 0; }