How to use Scene.delay()?
I'm making a game of snake (will post code later), and would like to slow down the drawing process. I've looked up scene.delay (which I don't know how to use properly) and also time.sleep. what is the best method and how do I implement it? Thanks!
The delay function doesn't actually slow down the drawing process. It calls a given function after a certain amount of time. It kind of tells a function to wait for <i>n</i> seconds before it is called.
Here's an example of the delay function:
<pre>from scene import *
self.color = (1,0,0)
def change_color(self): self.color = (0,1,0) def draw(self): background(*self.color) self.delay(3, self.change_color)
This draws a <i>red</i> screen, and the delay function will change the color to <i>green</i> after 3 dt have passed.
Another option to slow things down would be to pass the optional frame_interval parameter to the run function, like so: <pre>run(MyScene(), frame_interval=3)</pre>This would basically run the scene at 30 frames per second instead of 60 (passing 3 would be 20fps etc.).