Timer for Python game

import time

now = time.time()
future = now + 10
while time.time() < future:
    # do stuff
    pass

Alternatively, if you’ve already got your loop:

while True:
    if time.time() > future:
        break
    # do other stuff

This method works well with pygame, since it pretty much requires you to have a big main loop.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)