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