I'm trying to add a countdown timer to the top right of my python game
I do not want to have to import anything other than pygame...>>My game is at 50 fps my screen is 640x480
I'm trying to add a timer to the top right of the screen. The timer needs to count down from 10... I've tried tons of things and can't get it to work. So far this is what I have:
class Timer(games.Sprite): """ countdown timer """ def __init__(self): timer_message = games.Text( value = 10, size = 50, color = color.black, x = games.screen.width - 30, y = games.screen.height - 420) timer_delay = 50
I don't see any code for actually causing the timer to count down. Without any knowledge of the rest of your code, I would suggest using
class Timer(games.Sprite): def __init__(self): .... self.start() def start(self): while self.timer_message.value != 0: time.sleep(1) self.timer_message.value -= 1
And don't bother with assigning timer_delay.