Permalink
Browse files

move timing to main.cpp

  • Loading branch information...
1 parent 1f67375 commit d00b80b55f37e4628fe028cc5a116bf87430cd43 @cyxx committed Jun 21, 2016
Showing with 7 additions and 10 deletions.
  1. +0 −9 game.cpp
  2. +0 −1 game.h
  3. +7 −0 main.cpp
View
@@ -120,7 +120,6 @@ void Game::init() {
playVideo("DATA/INTRO.AVI");
_nextState = kStateGame;
}
- _lastFrameTimeStamp = _stub->getTimeStamp();
}
void Game::fini() {
@@ -232,14 +231,6 @@ void Game::mainLoop() {
break;
}
_stub->updateScreen();
-#ifndef __EMSCRIPTEN__
- const uint32_t end = _lastFrameTimeStamp + kCycleDelay;
- do {
- _stub->sleep(10);
- _stub->processEvents();
- } while (!_stub->_pi.fastMode && _stub->getTimeStamp() < end);
-#endif
- _lastFrameTimeStamp = _stub->getTimeStamp();
}
void Game::updateMouseButtonsPressed() {
View
@@ -450,7 +450,6 @@ struct Game {
int _stateSlot;
int _mixerSoundId;
int _mixerMusicId;
- uint32_t _lastFrameTimeStamp;
int _bitmapSequence;
uint8_t *_bitmapBuffer0;
View
@@ -74,8 +74,15 @@ int main(int argc, char *argv[]) {
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(mainLoop, kCycleDelay, 0);
#else
+ uint32_t lastFrameTimeStamp = g_stub->getTimeStamp();
while (!g_stub->_quit) {
g_game->mainLoop();
+ const uint32_t end = lastFrameTimeStamp + kCycleDelay;
+ do {
+ g_stub->sleep(10);
+ g_stub->processEvents();
+ } while (!g_stub->_pi.fastMode && g_stub->getTimeStamp() < end);
+ lastFrameTimeStamp = g_stub->getTimeStamp();
}
fini();
#endif

0 comments on commit d00b80b

Please sign in to comment.