本文整理汇总了C++中TimeManager::sleep方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeManager::sleep方法的具体用法?C++ TimeManager::sleep怎么用?C++ TimeManager::sleep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeManager
的用法示例。
在下文中一共展示了TimeManager::sleep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void LevelManager::run()
{
/* Behold, as I have been told
* what follows below
* is very important, you know! */
InputManager *inputManager = InputManager::getInstance();
TimeManager *timeManager = TimeManager::getInstance();
VideoManager *videoManager = VideoManager::getInstance();
EffectManager *effectManager = EffectManager::getInstance();
SketchManager *sketchManager = SketchManager::getInstance();
FPSLogger fps;
float freq_to_update = 1000.0f / 60.0f;
long lastUpdate = timeManager->getTicks();
while(!inputManager->hasQuitEvent()) {
/* Calculate the ticks that have passed. */
long ticks = timeManager->getTicks();
float ms = (float)(ticks - lastUpdate);
lastUpdate = ticks;
/* Cap FPS by sleeping a little. */
if(ms <= freq_to_update) {
float wait = freq_to_update - ms;
timeManager->sleep(wait);
}
/* Update the input state. */
inputManager->update(ms);
/* Update the level. */
if(level && ms > 0.0f) level->update(timeFactor * ms);
/* Update other things. */
effectManager->update(timeFactor * ms);
fps.update(ms);
/* Setup the videoManager for rendering. */
videoManager->clear();
videoManager->identity();
/* Render the level first, this will also apply our camera
* transformation, which is good, since the effect manager
* wants the same transformation. */
if(level) level->render();
effectManager->render();
fps.render();
/* Flip the video buffer. */
videoManager->flip();
/* Update level queue. */
if(queue) {
/* Remove old level. */
if(level)
delete level;
effectManager->clear();
sketchManager->clear();
/* Load new level. */
level = new Level(queueFileName);
queue = false;
timeFactor = 1.0f;
/* Loading the level might have taken some time, so we skip
* some ticks. */
lastUpdate = timeManager->getTicks();
}
}
}