]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
fps stuff
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 15 Sep 2015 01:25:39 +0000 (21:25 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 15 Sep 2015 01:25:39 +0000 (21:25 -0400)
src/main.cpp

index 905e4cdca2455af74f8041ffbc4d4dae51e6ba79..e07e258c8e08d872b156ec2dc26fed0d2d777990 100644 (file)
@@ -171,10 +171,15 @@ void render(){
                glRectf(build.loc.x, build.loc.y, build.loc.x + build.width, build.loc.y + build.height);
                ///BWAHHHHHHHHHHHH
                
-               float d = deltaTime;
-               float fps = (1000 / d);
+               static float d,fps;
+               static unsigned int div=0;
 
                ui.setFontSize(16);
+               if(++div==20){
+                       div=0;
+                       d=deltaTime;
+                       fps=(1000/d);
+               }
                ui.putText(-.98 + player.loc.x, .94, "FPS: %1.0f",fps);
                ui.putText(-.98 + player.loc.x, .88, "DT: %1.0f",d);
                ui.putText(player.loc.x,player.loc.y-(HLINE*10),"(%+1.3f,%+1.3f)",player.loc.x,player.loc.y);
@@ -197,8 +202,6 @@ void logic(){
        else if(player.left)player.vel.x=-.00075;
        else player.vel.x = 0;
 
-       std::cout << deltaTime << std::endl;
-
        currentWorld->detect(&player.loc,&player.vel,player.width);
        gw=currentWorld->getWidth();
        if(player.loc.x+player.width>-1+gw){