Answer the question
In order to leave comments, you need to log in
Why does the time.sleep command not work for me as it should?
Why, when executing this loop, falling asleep does not occur after update(), as it should, but after executing the next command after sleep?
The code below outputs:
Enter
Update
Enter
and only then goes to sleep.
Update
Input goes to
sleep
etc.
from time import sleep, time
FPS = 1
SEC_PER_FRAME = 1/FPS
def processInput():
print("Ввод")
def update():
print("Update")
while True:
start = time()
processInput()
update()
sleep(start + SEC_PER_FRAME - time())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question