Ver código fonte

improved timings

naelstrof 10 anos atrás
pai
commit
fd6f8273d3
1 arquivos alterados com 4 adições e 2 exclusões
  1. 4
    2
      main.cpp

+ 4
- 2
main.cpp Ver arquivo

@@ -44,8 +44,10 @@ int main( int argc, char** argv ) {
44 44
         // "ticking" the xengine makes it process all queued events.
45 45
         xengine->tick();
46 46
         // If the user presses any key on the keyboard, exit the application.
47
-        // Make sure a second has passed before allowing canceling
48
-        if ( time.tv_sec - start.tv_sec > 1 ) {
47
+        // Make sure at least a half second has passed before allowing canceling
48
+        double timei = double( time.tv_sec*1000000000L + time.tv_nsec )/1000000000.f;
49
+        double starti = double( start.tv_sec*1000000000L + start.tv_nsec )/1000000000.f;
50
+        if ( timei - starti > 0.5 ) {
49 51
             if ( xengine->m_keypressed ) {
50 52
                 printf( "X=0\n" );
51 53
                 printf( "Y=0\n" );