debug msgs
This commit is contained in:
parent
04e7b7da94
commit
aea1502487
@ -114,6 +114,10 @@ void Game::initGame(){
|
||||
*
|
||||
* @return @WinValue::PLAYERS if the players won, @WinValue::INVADERS is the invaders won, WinValue::NOBODY else (also in case of error)
|
||||
*/
|
||||
|
||||
#define START_TIMER() DEBUG_INSTR(debugTime = chrono::high_resolution_clock::now())
|
||||
#define PRINT_TIMER(X) DEBUG_MSG((X) << " :" << chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now()-debugTime).count())
|
||||
|
||||
WinValue Game::enterGameLoop(){ // returns when game is finished
|
||||
// computed in advance for performance reasons
|
||||
chrono::milliseconds maxFrameTime = chrono::milliseconds(1000/confData.maxFPS);
|
||||
@ -122,7 +126,11 @@ WinValue Game::enterGameLoop(){ // returns when game is finished
|
||||
unsigned fps = 0;
|
||||
typedef chrono::high_resolution_clock::time_point MyTimePoint;
|
||||
MyTimePoint fpsStartTime = {};
|
||||
|
||||
DEBUG_INSTR(MyTimePoint debugTime);
|
||||
while(window.isOpen()){
|
||||
DEBUG_INSTR(fflush(stdout));
|
||||
DEBUG_MSG("------------")
|
||||
|
||||
MyTimePoint startTime = chrono::high_resolution_clock::now();
|
||||
if(fpsStartTime.time_since_epoch()==chrono::seconds(0)){
|
||||
@ -131,26 +139,38 @@ WinValue Game::enterGameLoop(){ // returns when game is finished
|
||||
|
||||
pm->startFrame();
|
||||
|
||||
START_TIMER()
|
||||
managePlayers();
|
||||
PRINT_TIMER("manage players")
|
||||
START_TIMER()
|
||||
if(manageInvaders()) { // if they went down
|
||||
if (invadersTouchPlayer())return WinValue::INVADERS;
|
||||
tryAwakeGod();
|
||||
}
|
||||
PRINT_TIMER("manage invaders")
|
||||
|
||||
START_TIMER()
|
||||
if(manageGod())return WinValue::PLAYERS;
|
||||
if(arePlayersDead())return WinValue::GOD;
|
||||
PRINT_TIMER("god")
|
||||
|
||||
START_TIMER()
|
||||
moveMissiles();
|
||||
remCollidingProjectiles();
|
||||
moveTorpedos();
|
||||
remCollidingProjectiles();
|
||||
PRINT_TIMER("self collisions")
|
||||
|
||||
START_TIMER()
|
||||
checkMissilesAndPlayers();
|
||||
if(checkTorpedosAndInvaders())return WinValue::PLAYERS;
|
||||
PRINT_TIMER("collisions between entities")
|
||||
|
||||
if(arePlayersDead())return WinValue::INVADERS;
|
||||
|
||||
START_TIMER()
|
||||
displayAll(fps);
|
||||
PRINT_TIMER("display")
|
||||
|
||||
pm->endFrame();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user