end of game menu done
This commit is contained in:
parent
ea6b489126
commit
4c8bbef006
10
config.yml
10
config.yml
@ -1,6 +1,6 @@
|
||||
# General configuration
|
||||
general:
|
||||
maxFPS: 50
|
||||
maxFPS: 30
|
||||
|
||||
# Players config
|
||||
players:
|
||||
@ -25,7 +25,7 @@ players:
|
||||
# Enemies config
|
||||
invaders:
|
||||
fireCooldown: 20
|
||||
size: 25
|
||||
size: 40
|
||||
speed: 7
|
||||
distance: 10 # distance in pixels between invaders
|
||||
|
||||
@ -54,6 +54,6 @@ projectiles:
|
||||
# Grid definition
|
||||
# You can add more rows, make rows longer and add spaces
|
||||
grid:
|
||||
- "AAAAAAAAAAAA"
|
||||
- "BBBBBBBBBBBB"
|
||||
- "CCCCCCCCCCCC"
|
||||
- " "
|
||||
- " "
|
||||
- "B"
|
||||
|
@ -182,7 +182,7 @@ public:
|
||||
void drawFPS(unsigned fps) const;
|
||||
|
||||
PlayMode showInitialMenu();
|
||||
bool showDeathMenu() const;
|
||||
PlayMode showDeathMenu();
|
||||
unsigned getScreenHeight() const;
|
||||
unsigned getScreenWidth() const;
|
||||
|
||||
|
@ -41,7 +41,7 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
}
|
||||
|
||||
PlayMode PixelManager::showInitialMenu(){
|
||||
vector<string> entries {"single player","multi player (local)","EXIT"};
|
||||
vector<string> entries {"single player","multi player (local)","exit"};
|
||||
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
const unsigned xOffset = getScreenHeight() / 2 ;
|
||||
const unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||
@ -51,15 +51,15 @@ PlayMode PixelManager::showInitialMenu(){
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++initial.currentValue;
|
||||
if (initial.currentValue > initial.entries.size()) initial.currentValue = 0;
|
||||
if (initial.currentValue > initial.entries.size()-1) initial.currentValue = 0;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
}
|
||||
// go up
|
||||
if (window.isPressed({'z', false})){
|
||||
if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1;
|
||||
else --initial.currentValue;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
}// select option
|
||||
else if (window.isPressed({13, false})){
|
||||
switch(initial.currentValue){
|
||||
case 0:
|
||||
@ -68,14 +68,45 @@ PlayMode PixelManager::showInitialMenu(){
|
||||
return PlayMode::TWO_LOCAL;
|
||||
case 2:
|
||||
return PlayMode::EXIT;
|
||||
default:
|
||||
return PlayMode::SINGLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PixelManager::showDeathMenu() const {
|
||||
return true;
|
||||
PlayMode PixelManager::showDeathMenu() {
|
||||
vector<string> entries {"main menu","exit"};
|
||||
Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
const unsigned xOffset = getScreenHeight() / 2 ;
|
||||
const unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||
while(true){
|
||||
displayMenu(Position(yOffset,xOffset),death);
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++death.currentValue;
|
||||
if (death.currentValue > death.entries.size()-1) death.currentValue = 0;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
// go up
|
||||
if (window.isPressed({'z', false})){
|
||||
if (death.currentValue == 0) death.currentValue = death.entries.size()-1;
|
||||
else --death.currentValue;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}// select option
|
||||
else if (window.isPressed({13, false})){
|
||||
switch(death.currentValue){
|
||||
case 0:
|
||||
return PlayMode::NONE;
|
||||
case 1:
|
||||
return PlayMode::EXIT;
|
||||
default:
|
||||
return PlayMode::EXIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,9 +65,7 @@ void Game::managedGames() {
|
||||
enterGameLoop(); // will read the playMode
|
||||
handleScoreSaving();
|
||||
cout << "END OF GAME" << endl;
|
||||
break; // TODO remove
|
||||
if(!pm.showDeathMenu()) playMode = PlayMode::NONE; // back to the main menu
|
||||
|
||||
playMode = pm.showDeathMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user