MYFLAGS  := -Wall -pedantic -ansi
 
 VALFLAGS := --leak-check=full
-CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
+CXXFLAGS := ${MYFLAGS} ${OPTFLAGS}
 
 CXX := g++
 
 
  * last_Second := stores the time of the last second, used for ups and fps
  */
 int target_UPS = 100;
+float update_Wait = 0;
 
 int ups, fps;
 int update_Count, draw_Count;
-long int last_Second;
+MICRO last_Second;
+
+const int min_wait_milli = 20;
+const int min_wait_micro = min_wait_milli * 1000;
+const float game_step    = 10;
 
 int startUpdateThread(void*);
 int startDrawThread(void*);
 
     SDL_Thread* updates = SDL_CreateThread(startUpdateThread, NULL);
 
+    // for some reason this needs to be on the main thread ...?
     startDrawThread(NULL);
 
     SDL_WaitThread(updates, NULL);
 
 int startUpdateThread(void*)
 {
+    last_Second = tickCountMicro();
+
     while(is_Running)
     {
-        handleInput();
-        update(10);
+        MICRO time = tickCountMicro();
+            handleInput();
+            update(game_step);
+
+            updateFPSCounters();
+        time = tickCountMicro() - time;
 
-        updateFPSCounters();
+        float wait = (1000000.0 / target_UPS - time);
+        update_Wait += 0 < wait ? wait : 0;
 
-        SDL_Delay(10);
+        while(min_wait_micro < update_Wait)
+        {
+            update_Wait -= min_wait_micro;
+            SDL_Delay(min_wait_milli);
+        }
     }
 
     return 0;
 
 /// ***** Public Methods *****
 
 // returns the current microseconds from unix time
-long int tickCountMicro()
+MICRO tickCountMicro()
 {
   struct timeval tv;
   gettimeofday(&tv, 0);
 }
 
 // returns the current milliseconds from unix time
-long int tickCountMilli()
+MICRO tickCountMilli()
 {
   return tickCountMicro() / 1000;
 }
 
 // returns the current seconds from unix time
-long int tickCountSec()
+MICRO tickCountSec()
 {
   return tickCountMicro() / 1000000;
 }
 
 
 /// ***** Public Methods *****
 
+typedef long int MICRO;
+
 // returns the current seconds from program start
-long int tickCountSec();
+MICRO tickCountSec();
 
 // returns the current milliseconds from program start
-long int tickCountMilli();
+MICRO tickCountMilli();
 
 // returns the current microseconds from program start
-long int tickCountMicro();
+MICRO tickCountMicro();
 
 #endif // TICKS_H