diff --git a/headers/pixelManager.h b/headers/pixelManager.h index 8750792..4976f0e 100644 --- a/headers/pixelManager.h +++ b/headers/pixelManager.h @@ -29,6 +29,7 @@ using namespace std; #define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize() +typedef nsGui::GlutFont::GlutFonts Font; /*! * @class PixelManager @@ -172,16 +173,9 @@ public: * @param[in] pos : pixel coordinates of the text * @param[in] text : text to show on screen * @param[in] color : color of the text to show - * @fn void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const; + * @fn void drawText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const; */ - void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const; - - /*! - * @brief display the current screen refresh rate - * @param[in] fps : current framerate - * @fn void drawFPS(unsigned fps) const; - */ - void drawFPS(unsigned fps) const; + void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const; /*! * @brief show the title screen of the game @@ -226,10 +220,11 @@ public: /*! * @brief display the player name selection menu * @param[in] pID : player id + * @param[in] score : score of this player * @param[out] name : name selected by the player * @fn */ - void askPlayerNameMenu(playerID pID, string& name); + void askPlayerNameMenu(playerID pID, unsigned score, string& name); // y will be negative sometimes, so not unsigned diff --git a/src/drawEntity.cpp b/src/drawEntity.cpp index 4a88f12..a4fc9ea 100644 --- a/src/drawEntity.cpp +++ b/src/drawEntity.cpp @@ -125,15 +125,10 @@ void PixelManager::drawGodFace(int y, bool angry) const { } -void PixelManager::displayText(const Position& pos, const string& text,const nsGraphics::RGBAcolor& color) const { - window << Text(pos, text, color, GlutFont::GlutFonts::BITMAP_TIMES_ROMAN_24); +void PixelManager::drawText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color, Font font) const { + window << Text(pos, text, color, font); } -void PixelManager::drawFPS(unsigned fps) const { - window << Text(Position(getScreenWidth()-200, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite); -} - - vector PixelManager::mirrorData(const vector& inPixels, unsigned rowSize) { vector outPixels; diff --git a/src/drawMenu.cpp b/src/drawMenu.cpp index 2681de8..14207c6 100644 --- a/src/drawMenu.cpp +++ b/src/drawMenu.cpp @@ -30,7 +30,7 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){ startFrame(); drawSprite(menuBackground); drawSprite(logo,Position(100,50)); - displayText(Position(1150,700), "version 1.0.0"); + drawText(Position(1150, 700), "version 1.0.0"); size_t margin = 0; size_t cpt = 0; for(string& value : currentMenu.entries ){ @@ -77,16 +77,18 @@ PlayMode PixelManager::showInitialMenu(){ exit(0); } -void PixelManager::askPlayerNameMenu(playerID pID, string& name) { +void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name) { name = string(6, 'A'); size_t currentSelected = 0 ; chrono::milliseconds waitTime = chrono::milliseconds(100); while (window.isOpen()){ startFrame(); drawSprite(menuBackground); - displayText(Position(600,100),"Nom du joueur "+to_string(pID+1)); + drawText(Position(600, 100), "Nom du joueur " + to_string(pID + 1)); + drawText(Position(600, 150), "Score : " + to_string(score)); for (size_t i = 0; i < name.size(); ++i){ - displayText(Position(600+30*i,200),string(1,name[i]),(i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite); + drawText(Position(600 + 30 * i, 200), string(1, name[i]), + (i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite); } endFrame(); // go down diff --git a/src/game/display.cpp b/src/game/display.cpp index 2895280..1730160 100644 --- a/src/game/display.cpp +++ b/src/game/display.cpp @@ -37,8 +37,9 @@ void Game::displayAll(unsigned fps) const { displayGod(); - pm.drawFPS(fps); - + DEBUG_INSTR( + pm.drawText(Position(pm.getScreenWidth()-200, 20), "FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13); + ) for(size_t i=0;i bool {return p.isEliminated();}); } diff --git a/src/game/gameManagers.cpp b/src/game/gameManagers.cpp index c101684..8477e86 100644 --- a/src/game/gameManagers.cpp +++ b/src/game/gameManagers.cpp @@ -42,8 +42,6 @@ void Game::manageOnePlayer(playerID pID){ } } -/** Makes the players play once -*/ void Game::managePlayers(){ for(unsigned i=0;i