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


C++ Stopwatch::read方法代码示例

本文整理汇总了C++中Stopwatch::read方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::read方法的具体用法?C++ Stopwatch::read怎么用?C++ Stopwatch::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stopwatch的用法示例。


在下文中一共展示了Stopwatch::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nNodes

BVH::BVH(std::vector<FastBVH::Object*>* objects, uint32_t leafSize)
  : nNodes(0), nLeafs(0), leafSize(leafSize), build_prims(objects), flatTree(NULL) {
    Stopwatch sw;

    // Build the tree based on the input object data set.
    build();

    // Output tree build time and statistics
    double constructionTime = sw.read();
    LOG_STAT("Built BVH (%d nodes, with %d leafs) in %d ms", nNodes, nLeafs, (int)(1000*constructionTime));
  }
开发者ID:zzdever,项目名称:Multi-ScaleGranular,代码行数:11,代码来源:BVH.cpp

示例2: Run

int Game::Run(){
    win = new Window(1280,760);

    //The gmae timers start and end
    Stopwatch time;

    //Calls the init function to initilise everything
    if(init() == false){
        return -1;
    }

    //Gets the surface of the screen
    displaySurface = win->getGraphics();

    //initialises SDLs event handler
    SDL_Event event;

    //Gets a timestamp for calculating delta times between ticks
    double oldTime = GetTime();

    //Start the timer
    time.start();

    //The main game loop
    while(running){
        //initialises the player entity velocity to 0,
        //this resets velocity on each loop to prevent the player from carrying
        // on in one direction after the movement keys have stopped being pressed
        entity.velocityX = 0;
        entity.velocityY = 0;

        //Checks to see if an event has occured,
        while(SDL_PollEvent(&event)){
            onEvent(&event);
        }

        //Calculates the delta time for dealing with the tick since last loop
        const double newTime = GetTime();
        double dt = newTime - oldTime;
        oldTime = newTime;

        //Deals with all game state changes
        loop(dt);

        //deals with all rendering
        win->setText(" Score: " + std::to_string(score) + "       Time Left: " + std::to_string(60-(int)(time.read()/1000)) + "s");
        render();
        if(time.read() > 60000 && !theend){
            theend = true;
            time.stop();
            std::ofstream score;
            score.open("score.txt", std::ios::ate | std::ios::out);
            score << "Last score: " << this->score << "\n" << scorestring;
            score.flush();
            score.close();
        running=false;

        while(SDL_WaitEvent(&event)){
            if(event.key.keysym.sym == SDLK_RETURN)
                break;
        }
    }
}
    //this is only called when the game is exiting, makes sure the game exits cleanly with all memory cleared correctly
    cleanUp();

    return 0;
}
开发者ID:lutzee,项目名称:0x58,代码行数:68,代码来源:Game.cpp


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