I'm working on a Snake Game in Pygame, but I bumped into a little problem: my Snake moves too fast. I thought I could use a time.sleep(), but in this way the program stop itself and it doesn't register keys pressing anymore. So I looked on the internet for other options and I found out I could use thread. That was a good solution, but I actually can't restart my timer after I've used it.
import threading
def mythread():
print("hello")
t=threading.Timer(3.0,mythread)
I run the test code and I then I try to run the command
t.start()
but I receive this error message:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
t.start()
RuntimeError: threads can only be started once
I'd just like to be able to start the timer again, is there a way to do this?