Commits

Arne Babenhauserheide  committed ca2bfd7

FPS optimizations.

  • Participants
  • Parent commits ecbef97

Comments (0)

Files changed (2)

File code_swarm.py

 	self.reltime = self.core.load_text("rel time", font_size = 10.0, x=10, y=10)
 	self.visible.append(self.reltime)
 
-        # limit the FPS to 20 via pyglet internals
-        clock.set_fps_limit(20)
-
+        # limit the FPS to 50 via pyglet internals
+        clock.set_fps_limit(50)
+ 
 
     def show_change(self, author_name, filepath): 
 	"""Show a change by an author to a file."""
         [blob.draw() for blob in self.active.values()]
 	
 	# sleep for a blink, so we don't always max out the CPU
-	sleep(0.01)
+        # unneeded, because we set the fps limit in the __init__.
+	#sleep(0.01)

File fungus_swarm.py

 
 from random import random, choice, randint
 
-# Reduce CPU usage: sleep
-from time import sleep
+# Reduce CPU usage: clock
+from pyglet import clock
 
 #### Constants ####
 
 #: Do we want to never choose the last partner as next partner? 
 NEVER_SELECT_LAST_AS_NEXT = True
 # The distribution of sexes among the blobs. 
-#SEX_DISTRIBUTION = ["male", "male", "female", "female", None]
+SEX_DISTRIBUTION = ["male", "male", "female", "female", None]
 #SEX_DISTRIBUTION = ["male", None]
-SEX_DISTRIBUTION = ["male", "female"]
+#SEX_DISTRIBUTION = ["male", "female"]
 #SEX_DISTRIBUTION = ["male", "female", None, None, None]
 #SEX_DISTRIBUTION = ["male", "male", "male", "male", "male", "female", None]
 #: Strengths of random movement
 	self.blob_batch = self.core.batch()
 	# Show the batch. If we now add a sprite with this batch, it is shown automatically. 
 	self.visible.append(self.blob_batch)
+
+        # limit the FPS to 50 via pyglet internals
+        clock.set_fps_limit(50)
+
 	
         self.blobs = []
         for i in range(NUMBER_OF_BLOBS):
         	blob.update()
 		self.keep_on_screen(blob)
 	# sleep for a blink, so we don't always max out the CPU
-	sleep(0.01)
+	#sleep(0.001)