Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7919f8f722
@ -78,9 +78,9 @@ players:
|
|||||||
user2:
|
user2:
|
||||||
color: blue
|
color: blue
|
||||||
keys:
|
keys:
|
||||||
left: 4
|
left: k
|
||||||
right: 6
|
right: m
|
||||||
shoot: 5
|
shoot: l
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
|||||||
@ -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
|
||||||
@ -209,9 +210,10 @@ 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
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// Syntax : DEBUG(cout << "hey" << endl)
|
// Syntax : DEBUG(cout << "hey" << endl)
|
||||||
// The debug flag defintion has been set here, but normally we would add it to the MakeFile
|
// The debug flag defintion has been set here, but normally we would add it to the MakeFile
|
||||||
#define DEBUG_FLAG
|
//#define DEBUG_FLAG
|
||||||
|
|
||||||
#ifdef DEBUG_FLAG
|
#ifdef DEBUG_FLAG
|
||||||
#define DEBUG_MSG(X) cerr << "DEBUG: " << X << endl;
|
#define DEBUG_MSG(X) cerr << "DEBUG: " << X << endl;
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,10 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
|||||||
startFrame();
|
startFrame();
|
||||||
drawSprite(menuBackground, Position(0, 0));
|
drawSprite(menuBackground, Position(0, 0));
|
||||||
drawSprite(logo,Position(100,50));
|
drawSprite(logo,Position(100,50));
|
||||||
drawText(Position(1150, 700), "version 1.0.0");
|
drawText(Position(10, 692), "tips:",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
|
||||||
|
drawText(Position(10, 702), "use 'z','s','q','d' and 'enter' to navigate the menus",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
|
||||||
|
drawText(Position(10, 712), "see the configuration file for player specific key bindings",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
|
||||||
|
drawText(Position(1150, 712), "version 1.0.0");
|
||||||
unsigned margin = 0;
|
unsigned margin = 0;
|
||||||
unsigned cpt = 0;
|
unsigned cpt = 0;
|
||||||
for(string& value : currentMenu.entries ){
|
for(string& value : currentMenu.entries ){
|
||||||
@ -41,24 +44,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, Position(0, 0));
|
drawSprite(menuBackground, Position(0, 0));
|
||||||
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 +153,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