DrawText_GUI(buffer, 8, WINDOW_HEIGHT-26, 127);
// sync to 30 fps
Wait_Clock(30);
// check if user is trying to exit
if (KEY_DOWN(VK_ESCAPE))
{
// send message to windows to exit
PostMessage(main_window_handle, WM_DESTROY, 0, 0);
// set exit state
game_state = GAME_STATE_SHUTDOWN;
}
}
else if (game_state == GAME_STATE_SHUTDOWN)
{
// in this state shut everything down and release resources
// switch to exit state
game_state = GAME_STATE_EXIT;
}
return 1;
}
/* CLOCK FUNCTIONS ************************************************************************/
DWORD Get_Clock(void)
{
// this function returns the current tick count
// return time
return GetTickCount();
}
DWORD Start_Clock(void)
{
// this function starts the block, that is, saves the current count,
// use in conjunction with Wait_Clock()
return (start_clock_count = Get_Clock());
}
DWORD Wait_Clock(DWORD count)
{
// this function is used to wait for a specific number of clicks since
// the call to Start_Clock
while (Get_Clock() - start_clock_count < count)
;
return Get_Clock();
}
