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] pos : pixel coordinates of the menu
|
||||||
* @param[in,out] currentMenu : menu struct conteining the menu option
|
* @param[in,out] currentMenu : menu struct conteining the menu option
|
||||||
* @param[in] rankings : the current top 10 players
|
* @param[in] rankings : the current top 10 players
|
||||||
|
* @param[in] winner : the winner of the game
|
||||||
* @fn void displayMenu(const Position& pos, Menu& currentMenu);
|
* @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
|
* @brief display text on screen
|
||||||
* @param[in] pos : pixel coordinates of the text
|
* @param[in] pos : pixel coordinates of the text
|
||||||
@ -208,10 +209,11 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* @brief show the menu after a player lose, or all invader has been defeated
|
* @brief show the menu after a player lose, or all invader has been defeated
|
||||||
* @return true if the player plays again, else false
|
* @return true if the player plays again, else false
|
||||||
* @param[in] rankings : the current top 5 score
|
* @param[in] rankings : the current top 5 score
|
||||||
|
* @param[in] winner : the winner of the game
|
||||||
* @fn bool showDeathMenu();
|
* @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
|
* @brief give the height of the screen
|
||||||
|
@ -64,6 +64,7 @@ void Game::handleScoreSaving(){
|
|||||||
void Game::managedGames() {
|
void Game::managedGames() {
|
||||||
|
|
||||||
playMode = PlayMode::NONE;
|
playMode = PlayMode::NONE;
|
||||||
|
WinValue whoWon;
|
||||||
|
|
||||||
while(playMode!=PlayMode::EXIT){
|
while(playMode!=PlayMode::EXIT){
|
||||||
if(playMode==PlayMode::NONE){
|
if(playMode==PlayMode::NONE){
|
||||||
@ -71,10 +72,10 @@ void Game::managedGames() {
|
|||||||
}else{
|
}else{
|
||||||
DEBUG_MSG("Starting game")
|
DEBUG_MSG("Starting game")
|
||||||
initGame();
|
initGame();
|
||||||
enterGameLoop(); // will read the playMode
|
whoWon = enterGameLoop(); // will read the playMode
|
||||||
DEBUG_MSG("END End of game")
|
DEBUG_MSG("END End of game")
|
||||||
handleScoreSaving();
|
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();
|
startFrame();
|
||||||
drawSprite(menuBackground);
|
drawSprite(menuBackground);
|
||||||
drawSprite(logo,Position(100,50));
|
drawSprite(logo,Position(100,50));
|
||||||
drawText(Position(1150, 700), "version 1.0.0");
|
drawText(Position(1150, 700), "version 1.0.0");
|
||||||
unsigned margin = 0;
|
unsigned margin = 0;
|
||||||
unsigned cpt = 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 ){
|
for(string& value : currentMenu.entries ){
|
||||||
displayButton(Position(0,0+margin)+ pos, value, (currentMenu.currentValue == cpt) ? currentMenu.selectedColor : currentMenu.unSelectedColor );
|
displayButton(Position(0,0+margin)+ pos, value, (currentMenu.currentValue == cpt) ? currentMenu.selectedColor : currentMenu.unSelectedColor );
|
||||||
++cpt;
|
++cpt;
|
||||||
margin += 50;
|
margin += 50;
|
||||||
}
|
}
|
||||||
margin = 0;
|
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){
|
for (auto& value: rankings){
|
||||||
drawText(Position(0,400+margin),value.name,nsGraphics::KWhite);
|
drawText(Position(0,400+margin),value.name,nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
|
||||||
drawText(Position(140,400+margin),to_string(value.score),nsGraphics::KWhite);
|
drawText(Position(140,400+margin),to_string(value.score),nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
|
||||||
margin += 50;
|
margin += 15;
|
||||||
}
|
}
|
||||||
endFrame();
|
endFrame();
|
||||||
}
|
}
|
||||||
@ -147,14 +150,14 @@ void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name)
|
|||||||
exit(0);
|
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"};
|
vector<string> entries {"retry","main menu"};
|
||||||
Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||||
unsigned xOffset = getScreenHeight() / 2 ;
|
unsigned xOffset = getScreenHeight() / 2 ;
|
||||||
unsigned yOffset = getScreenWidth() / 2 - 90;
|
unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||||
while(window.isOpen()){
|
while(window.isOpen()){
|
||||||
displayMenu(Position(yOffset,xOffset),death,rankings);
|
displayMenu(Position(yOffset,xOffset),death,rankings,winner);
|
||||||
// go down
|
// go down
|
||||||
if (window.isPressed({'s', false})){
|
if (window.isPressed({'s', false})){
|
||||||
++death.currentValue;
|
++death.currentValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user