Browse Source

change fps compensation delta

micha 1 day ago
parent
commit
41a8fd83c6
1 changed files with 13 additions and 2 deletions
  1. 13 2
      tkray/dmx.py

+ 13 - 2
tkray/dmx.py

@@ -317,6 +317,8 @@ add=0
 modes_data = {}
 modes_time = time.time()
 
+core_tick_t = time.time()
+
 while not pyray.window_should_close():
     pyray.begin_drawing()
 
@@ -463,8 +465,6 @@ while not pyray.window_should_close():
         pyray.draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
         pyray.draw_rectangle(int(old_x-1),int(old_y-10),2,20,[255,0,255,255])
 
-        pyray.end_drawing()
-        time.sleep(1/11)
 
         for i,v in enumerate(mouse_old):
             if v == "release":
@@ -478,6 +478,17 @@ while not pyray.window_should_close():
             fps_count = frame_count
             frame_count = 0
 
+        pyray.end_drawing()
+
+        # frame tick speed, CPU LOAD. ------
+        delta = 1/10
+        if delta > (time.time()-core_tick_t):
+            delta -= (time.time()-core_tick_t)
+        #print(delta)
+        time.sleep(delta)
+        core_tick_t = time.time()
+        # --------------------------------
+
     except KeyboardInterrupt as e:
         raise e
     except Exception as e:# KeyInterupt