How to make timer for a game loop?

前端 未结 5 1822
别跟我提以往
别跟我提以往 2021-02-06 16:21

I want to time fps count, and set it\'s limit to 60 and however i\'ve been looking throught some code via google, I completly don\'t get it.

5条回答
  •  半阙折子戏
    2021-02-06 17:21

    check this one out:

    //Creating Digital Watch in C++
    #include
    #include
    using namespace std;
    
    struct time{
    
    int hr,min,sec;
    };
    int main()
    {
    time a;
    a.hr = 0;
    a.min = 0;
    a.sec = 0;
    
    for(int i = 0; i<24; i++)
    {
        if(a.hr == 23)
        {
            a.hr = 0;
        }
    
        for(int j = 0; j<60; j++)
        {
            if(a.min == 59)
            {
                a.min = 0;
            }
    
            for(int k = 0; k<60; k++)
            {
                if(a.sec == 59)
                {
                    a.sec = 0;
                }
    
                cout<

提交回复
热议问题