From e606a641afcd93ba681fbec807ecc3deae2ed72f Mon Sep 17 00:00:00 2001 From: SIMAILA Djalim Date: Mon, 10 Jan 2022 17:03:06 +0100 Subject: [PATCH 1/3] now we have a little message in the death menu to tell who won --- headers/pixelManager/pixelManager.h | 8 +++++--- src/game/gameBasics.cpp | 5 +++-- src/pixelManager/drawMenus.cpp | 17 ++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/headers/pixelManager/pixelManager.h b/headers/pixelManager/pixelManager.h index 6b9eb2f..35802b1 100644 --- a/headers/pixelManager/pixelManager.h +++ b/headers/pixelManager/pixelManager.h @@ -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& rankings); + void displayMenu(const Position& pos, Menu& currentMenu, const vector& rankings,const WinValue& winner); /*! * @brief display text on screen * @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 * @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(); */ - bool showDeathMenu(const vector& rankings); + bool showDeathMenu(const vector& rankings,const WinValue& winner); /*! * @brief give the height of the screen diff --git a/src/game/gameBasics.cpp b/src/game/gameBasics.cpp index 3a6bf8f..6550c82 100644 --- a/src/game/gameBasics.cpp +++ b/src/game/gameBasics.cpp @@ -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; } } } diff --git a/src/pixelManager/drawMenus.cpp b/src/pixelManager/drawMenus.cpp index aeb5b0d..e5784d0 100644 --- a/src/pixelManager/drawMenus.cpp +++ b/src/pixelManager/drawMenus.cpp @@ -41,24 +41,27 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){ } -void PixelManager::displayMenu(const Position& pos, Menu& currentMenu, const vector& rankings){ +void PixelManager::displayMenu(const Position& pos, Menu& currentMenu, const vector& 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& rankings) { +bool PixelManager::showDeathMenu(const vector& rankings,const WinValue& winner) { vector 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; From fbaab4a9d877a1002f384fd66af5f2ba09a6b8dd Mon Sep 17 00:00:00 2001 From: SIMAILA Djalim Date: Mon, 10 Jan 2022 17:21:24 +0100 Subject: [PATCH 2/3] minor stuff all should be good .w. --- config.yml | 8 ++++---- headers/utils.h | 2 +- src/pixelManager/drawMenus.cpp | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config.yml b/config.yml index 460e3f9..1d44b7a 100644 --- a/config.yml +++ b/config.yml @@ -68,7 +68,7 @@ players: startXPosition: 600 fireCooldown: 10 speed: 10 - lives: 100 + lives: 3 user1: color: red keys: @@ -78,9 +78,9 @@ players: user2: color: blue keys: - left: 4 - right: 6 - shoot: 5 + left: k + right: m + shoot: là ############################# diff --git a/headers/utils.h b/headers/utils.h index eaf54b6..d194ff0 100644 --- a/headers/utils.h +++ b/headers/utils.h @@ -25,7 +25,7 @@ // Syntax : DEBUG(cout << "hey" << endl) // 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 #define DEBUG_MSG(X) cerr << "DEBUG: " << X << endl; diff --git a/src/pixelManager/drawMenus.cpp b/src/pixelManager/drawMenus.cpp index e5784d0..c23aff7 100644 --- a/src/pixelManager/drawMenus.cpp +++ b/src/pixelManager/drawMenus.cpp @@ -29,7 +29,10 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){ startFrame(); drawSprite(menuBackground); 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 cpt = 0; for(string& value : currentMenu.entries ){ From 75acafc848b6758042b7cad31c0652c0cb89a74a Mon Sep 17 00:00:00 2001 From: SIMAILA Djalim Date: Mon, 10 Jan 2022 17:22:14 +0100 Subject: [PATCH 3/3] u saw nothing --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 1d44b7a..4079253 100644 --- a/config.yml +++ b/config.yml @@ -80,7 +80,7 @@ players: keys: left: k right: m - shoot: là + shoot: l #############################