From: Patrik Gornicz Date: Sun, 7 Dec 2008 19:57:11 +0000 (-0500) Subject: reworked ups/fps/paused logic X-Git-Tag: physics-premerge~77 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=c46074c1fc66612c5ea0bfa1f4441491e296703d;p=libbear.git reworked ups/fps/paused logic --- diff --git a/src/GameStates/Paused.cpp b/src/GameStates/Paused.cpp index 20ef061..fea6de4 100644 --- a/src/GameStates/Paused.cpp +++ b/src/GameStates/Paused.cpp @@ -46,9 +46,9 @@ void Paused::draw(bool on_top) const bool Paused::pushMe() const { - return cfg::pause(); + return cfg::paused(); } bool Paused::popMe() const { - return cfg::unPause(); + return !cfg::paused(); } diff --git a/src/config/config.cpp b/src/config/config.cpp index 3b694ba..69406bc 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -27,6 +27,8 @@ /// ***** Private Method Headers ***** /// ***** Private Variables ***** +bool fPaused = false; + /// ***** Initializers/Cleaners ***** void cfg::init() @@ -43,13 +45,10 @@ void cfg::clean() /// ***** Public Methods ***** -bool cfg::pause() -{ - return input::wasPressed(key::pause); -} -bool cfg::unPause() +bool cfg::paused() { - return input::wasPressed(key::pause); + fPaused = input::wasPressed(key::pause) ? !fPaused : fPaused; + return fPaused; } bool cfg::endGame() @@ -70,4 +69,13 @@ bool cfg::mouseWellOff() return input::wasReleased(key::well); } +bool cfg::showFPS() +{ + return true; +} +bool cfg::showUPS() +{ + return true; +} + /// ***** Private Methods ***** diff --git a/src/config/config.h b/src/config/config.h index c794f65..8c7143f 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -28,12 +28,14 @@ namespace cfg bool endGame(); - bool pause(); - bool unPause(); + bool paused(); bool mouseWellFollow(); bool mouseWellOn(); bool mouseWellOff(); + + bool showFPS(); + bool showUPS(); } #endif // CONFIG_H diff --git a/src/debug.h b/src/debug.h index 2862cc2..6085003 100644 --- a/src/debug.h +++ b/src/debug.h @@ -36,11 +36,5 @@ void DASSERT(bool fBreak); // comment out when not debugging #define DEBUGGING -// comment out to suppress warnings -#define WARNINGS - -// comment out to prevent FPS and UPS printing -#define FPSUPS - #endif // DEBUG_H diff --git a/src/game.cpp b/src/game.cpp index 08f9530..5098ed8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -83,18 +83,24 @@ void game::handleInput() { creator::handleInput(); + int last = active_States.size() -1; - if(running->pushMe()) + if(active_States[last] != running && running->pushMe()) + { push_State = running; + } - if(paused->pushMe()) + if(active_States[last] != paused && paused->pushMe()) + { push_State = paused; + } - if(creating_Polygon->pushMe()) + if(active_States[last] != creating_Polygon && creating_Polygon->pushMe()) + { push_State = creating_Polygon; + } - int last = active_States.size() -1; for( int i = 0; i <= last; i++ ) @@ -113,21 +119,18 @@ void game::handleInput() void game::update(float time_step) { - if(push_State != NULL) - { - // don't want to pop and push same state, pop wins arbitrary - if(!pop_State) - active_States.push_back(push_State); - - push_State = NULL; - } - if(pop_State) { active_States.pop_back(); pop_State = false; } + if(push_State != NULL) + { + active_States.push_back(push_State); + push_State = NULL; + } + int last = active_States.size() -1; for( int i = 0; i <= last; diff --git a/src/main.cpp b/src/main.cpp index e932742..0efd748 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -182,10 +182,14 @@ void updateFPSCounters() last_Second = tickCountMicro(); -#ifdef FPSUPS - cout << "ups:\t" << ups << endl; - cout << "fps:\t" << fps << endl; -#endif + if(cfg::showFPS()) + { + cout << "fps:\t" << fps << endl; + } + if(cfg::showUPS()) + { + cout << "ups:\t" << ups << endl; + } } }