0

I've created a game; in which one of the main components is a countdown timer- however this timer is delayed and I am not able to deduce why.

This is how I have the timer set up:

loops = 0
minute = 1
tens = 0
ones = 0 

#Timer Calculation
    screen.blit(cloudSky, (0,0))
    if go == True:
        loops = loops + 1
        if (loops % 60)== 0:
            if ones == 0 and tens == 0 and minute != 0:
                tens = 6
                ones = 0
                minute = minute - 1

            if ones == 0 and tens != 0:
                ones = 9
                tens = tens - 1

            elif ones != 0:
                ones = ones - 1

            elif tens == 0 and ones == 0:
                tens = 5
                minute = minute - 1

            elif ones == 0 and tens != 0:
                tens = tens - 1


            if minute <= 0 and tens == 0 and ones == 0:
                go = False

#Draw Clock Time
time = timeFont.render(str (minute)+ ":" + str (tens) + str (ones), True, WHITE)
screen.blit(time, (750,10))

Any help is greatly appreciated!

Student
  • 39
  • 1
  • 11
  • 1
    You say the timer is "delayed" but what do you mean by that? Do you have a second timer to compare to this one? Your variable names suggest that you want it to decrement once per second. But you've presented only the logic of the counter itself, which says nothing about how often it gets called. At the moment, your question doesn't make much sense. You need to seriously rethink what you are asking. – Paul Cornelius Jun 17 '17 at 04:06
  • I'm very sorry! The timer is not being called anywhere as it is not a function, but I have it ongoing as soon as I hit play on the screen. It shows on the screen with the code that is under where I have it commented as "#draw clock time" I would like it to decrement once per second, however it seems to be decrementing at once every 6 seconds. – Student Jun 17 '17 at 07:31
  • 1
    The code you show here is just a down-counter. The counting rate depends not on when it starts but by how frequently it is called. You don't show that so it's pretty hard to suggest anything. – Paul Cornelius Jun 20 '17 at 00:48

0 Answers0