当前位置: 首页>>代码示例>>C++>>正文


C++ TimeManager::sleep方法代码示例

本文整理汇总了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();
                }
            }
        }
开发者ID:sjuxax,项目名称:JVGS,代码行数:73,代码来源:LevelManager.cpp


注:本文中的TimeManager::sleep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。