now we have a little message in the death menu to tell who won
This commit is contained in:
parent
1ae410638e
commit
e606a641af
@ -186,9 +186,10 @@ public:
|
||||
* @param[in] pos : pixel coordinates of the menu
|
||||
* @param[in,out] currentMenu : menu struct conteining the menu option
|
||||
* @param[in] rankings : the current top 10 players
|
||||
* @param[in] winner : the winner of the game
|
||||
* @fn void displayMenu(const Position& pos, Menu& currentMenu);
|
||||
*/
|
||||
void displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings);
|
||||
void displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings,const WinValue& winner);
|
||||
/*!
|
||||
* @brief display text on screen
|
||||
* @param[in] pos : pixel coordinates of the text
|
||||
@ -209,9 +210,10 @@ public:
|
||||
* @brief show the menu after a player lose, or all invader has been defeated
|
||||
* @return true if the player plays again, else false
|
||||
* @param[in] rankings : the current top 5 score
|
||||
* @param[in] winner : the winner of the game
|
||||
* @fn bool showDeathMenu();
|
||||
*/
|
||||
bool showDeathMenu(const vector<ScoreLink>& rankings);
|
||||
bool showDeathMenu(const vector<ScoreLink>& rankings,const WinValue& winner);
|
||||
|
||||
/*!
|
||||
* @brief give the height of the screen
|
||||
|
@ -64,6 +64,7 @@ void Game::handleScoreSaving(){
|
||||
void Game::managedGames() {
|
||||
|
||||
playMode = PlayMode::NONE;
|
||||
WinValue whoWon;
|
||||
|
||||
while(playMode!=PlayMode::EXIT){
|
||||
if(playMode==PlayMode::NONE){
|
||||
@ -71,10 +72,10 @@ void Game::managedGames() {
|
||||
}else{
|
||||
DEBUG_MSG("Starting game")
|
||||
initGame();
|
||||
enterGameLoop(); // will read the playMode
|
||||
whoWon = enterGameLoop(); // will read the playMode
|
||||
DEBUG_MSG("END End of game")
|
||||
handleScoreSaving();
|
||||
if(!pm->showDeathMenu(sm.scores))playMode = PlayMode::NONE;
|
||||
if(!pm->showDeathMenu(sm.scores,whoWon))playMode = PlayMode::NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,24 +41,27 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
}
|
||||
|
||||
|
||||
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings){
|
||||
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings, const WinValue& winner){
|
||||
startFrame();
|
||||
drawSprite(menuBackground);
|
||||
drawSprite(logo,Position(100,50));
|
||||
drawText(Position(1150, 700), "version 1.0.0");
|
||||
unsigned margin = 0;
|
||||
unsigned cpt = 0;
|
||||
if (winner == WinValue::PLAYERS) drawText(Position(0-55,0-20)+ pos,"The players won, earth is now safe",nsGraphics::KWhite);
|
||||
else if (winner == WinValue::INVADERS) drawText(Position(0-55,0-20)+ pos,"The invaders have reached earth",nsGraphics::KWhite);
|
||||
else drawText(Position(0-55,0-20)+ pos,"God won, as His power are infinite",nsGraphics::KWhite);
|
||||
for(string& value : currentMenu.entries ){
|
||||
displayButton(Position(0,0+margin)+ pos, value, (currentMenu.currentValue == cpt) ? currentMenu.selectedColor : currentMenu.unSelectedColor );
|
||||
++cpt;
|
||||
margin += 50;
|
||||
}
|
||||
margin = 0;
|
||||
drawText(Position(0,350), "Top 10 des meilleurs joueurs",nsGraphics::KWhite);
|
||||
drawText(Position(0,350), "Top 10 of the best players",nsGraphics::KWhite);
|
||||
for (auto& value: rankings){
|
||||
drawText(Position(0,400+margin),value.name,nsGraphics::KWhite);
|
||||
drawText(Position(140,400+margin),to_string(value.score),nsGraphics::KWhite);
|
||||
margin += 50;
|
||||
drawText(Position(0,400+margin),value.name,nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
|
||||
drawText(Position(140,400+margin),to_string(value.score),nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
|
||||
margin += 15;
|
||||
}
|
||||
endFrame();
|
||||
}
|
||||
@ -147,14 +150,14 @@ void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
bool PixelManager::showDeathMenu(const vector<ScoreLink>& rankings) {
|
||||
bool PixelManager::showDeathMenu(const vector<ScoreLink>& rankings,const WinValue& winner) {
|
||||
vector<string> entries {"retry","main menu"};
|
||||
Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
unsigned xOffset = getScreenHeight() / 2 ;
|
||||
unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||
while(window.isOpen()){
|
||||
displayMenu(Position(yOffset,xOffset),death,rankings);
|
||||
displayMenu(Position(yOffset,xOffset),death,rankings,winner);
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++death.currentValue;
|
||||
|
Loading…
Reference in New Issue
Block a user