end menu score display
This commit is contained in:
parent
53f0785fee
commit
1e6892f6b1
@ -8,10 +8,15 @@
|
||||
# run for a pleasant experience it should be above 30
|
||||
# maxFPS: 30
|
||||
#
|
||||
# The theme setting deffines which theme will be used during gameplay sesssion.
|
||||
# For a more custom experience use the 'bad' theme, for a more eye pleasant
|
||||
# experience use the 'good' theme.
|
||||
#
|
||||
general:
|
||||
maxFPS: 30
|
||||
theme: bad
|
||||
|
||||
|
||||
#############################
|
||||
# #
|
||||
# Player configuration #
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "utils.h"
|
||||
#include "playMode.h"
|
||||
#include "menu.h"
|
||||
#include "scoresManager.h"
|
||||
#include "mySprite.h"
|
||||
|
||||
using namespace std;
|
||||
@ -178,6 +179,14 @@ public:
|
||||
*/
|
||||
void displayMenu(const Position& pos, Menu& currentMenu);
|
||||
|
||||
/*!
|
||||
* @brief display a menu on screen
|
||||
* @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
|
||||
* @fn void displayMenu(const Position& pos, Menu& currentMenu);
|
||||
*/
|
||||
void displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings);
|
||||
/*!
|
||||
* @brief display text on screen
|
||||
* @param[in] pos : pixel coordinates of the text
|
||||
@ -197,9 +206,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
|
||||
* @fn bool showDeathMenu();
|
||||
*/
|
||||
bool showDeathMenu();
|
||||
bool showDeathMenu(const vector<ScoreLink>& rankings);
|
||||
|
||||
/*!
|
||||
* @brief give the height of the screen
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* @file ScoreManager.h
|
||||
* @file scoresManager.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
|
@ -73,7 +73,7 @@ void Game::managedGames() {
|
||||
enterGameLoop(); // will read the playMode
|
||||
handleScoreSaving();
|
||||
cout << "END OF GAME" << endl;
|
||||
if(!pm->showDeathMenu())playMode = PlayMode::NONE;
|
||||
if(!pm->showDeathMenu(sm.scores))playMode = PlayMode::NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,29 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
endFrame();
|
||||
}
|
||||
|
||||
|
||||
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings){
|
||||
startFrame();
|
||||
drawSprite(menuBackground);
|
||||
drawSprite(logo,Position(100,50));
|
||||
drawText(Position(1150, 700), "version 1.0.0");
|
||||
unsigned margin = 0;
|
||||
unsigned cpt = 0;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
endFrame();
|
||||
}
|
||||
|
||||
PlayMode PixelManager::showInitialMenu(){
|
||||
vector<string> entries {"single player","multi player (local)","exit"};
|
||||
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
@ -124,14 +147,14 @@ void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
bool PixelManager::showDeathMenu() {
|
||||
bool PixelManager::showDeathMenu(const vector<ScoreLink>& rankings) {
|
||||
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);
|
||||
displayMenu(Position(yOffset,xOffset),death,rankings);
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++death.currentValue;
|
||||
|
Loading…
Reference in New Issue
Block a user