Permalink
Browse files

Add a simpler in-game pause to allow to look around if needed (bound …

…to 'p')
  • Loading branch information...
1 parent 3a9f965 commit a74fcafe66af143e8211e93dfca4e2e0b4c54ed5 Baptiste Jonglez committed Jun 29, 2011
Showing with 30 additions and 4 deletions.
  1. +2 −1 README
  2. +24 −2 src/ap_play.cpp
  3. +2 −0 src/ap_play.h
  4. +2 −1 src/menu.cpp
View
3 README
@@ -37,7 +37,8 @@ X/PERIOD .......... Fire Yellow Portal
SPACE/5 ........... Fire 'Next' Portal
C ................. Clear Portals
-ESC/P/F1 .......... Pause Game Menu
+ESC/F1 ............ Menu
+P ................. In-game Pause
F2 ................ Change Portal Render
F3 ................ Set to Default Speed
+ ................. Increase Game Speed
View
26 src/ap_play.cpp
@@ -69,6 +69,7 @@ Game::Game(level &level) : lvl(level),
NULLOBJ(level.objm.NULLOBJ)
{
pause = false;
+ light_pause = false;
}
void Game::set_status(string status) {
@@ -732,9 +733,9 @@ int Game::move_player () {
break;
case '?' : help_menu (); break;
case 27 : // ASCII for escape
- case KEY_F(1) :
+ case KEY_F(1) : pause = true; break;
case 'P' :
- case 'p' : pause = true; break;
+ case 'p' : light_pause = true; break;
case KEY_F(2) :
cheatview = (cheatview + 1) % 4;
switch (cheatview) {
@@ -848,6 +849,23 @@ int Game::move_player () {
return 1;
}
+void light_pause(MapPack &mappack) {
+ mappack.lvl.pager.set_status(mappack.lvl.ticks, "Game paused (press 'p' to resume)");
+ mappack.lvl.pager.print_status(mappack.lvl.ticks);
+
+ refresh();
+ restms(10);
+ setblocking(true);
+ int input;
+ do {
+ input = getinput();
+ } while (input != 'p' && input != 'P');
+ flushinput();
+ setblocking(false);
+
+ mappack.lvl.pager.set_status(mappack.lvl.ticks, "Game resumed");
+}
+
int play(MapPack &mappack) {
unsigned long long int start, stop;
double seconds;
@@ -882,6 +900,10 @@ int play(MapPack &mappack) {
}
if (game.physics() < 0) return 0;
+ if (game.light_pause) {
+ light_pause(mappack);
+ game.light_pause = false;
+ }
if (game.pause) {
if (pause_menu(mappack) == -1) return 0;
game.pause = false;
View
2 src/ap_play.h
@@ -51,6 +51,8 @@ class Game {
Game(level&);
// whether the user requested the pause menu or not
bool pause;
+ // in-game lightweight pause menu
+ bool light_pause;
bool still_alive();
bool has_won();
int physics();
View
3 src/menu.cpp
@@ -126,7 +126,8 @@ void help_menu () {
"SPACE/5 ........... Fire 'Next' Portal",
"C ................. Clear Portals",
"",
- "ESC/P/F1 .......... Pause Game Menu",
+ "ESC/F1 ............ Menu",
+ "P ................. In-game Pause",
"F2 ................ Change Portal Render",
"F3 ................ Set to Default Speed",
"+ ................. Increase Game Speed",

0 comments on commit a74fcaf

Please sign in to comment.