K
K
Kuvira2017-04-13 16:16:45
Python
Kuvira, 2017-04-13 16:16:45

How to reset timer in python?

def enemyspawn(enemies,screen):
    stg = Settings()
    timer = pygame.time.get_ticks()
    if timer>=3600:
        r = random.randint(0, 736)
        enemy = Alien(r, screen)
        enemies.add(enemy)
        timer= 0

The problem is that the last command does not give any result. Pycharm writes that the timer variable in the last line is not used. Is it possible to somehow reset the value of the timer variable, or should the timer be reset in another way? Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2017-04-13
@GavriKos

If this is the whole body of the method, then the last action is simply meaningless. With a new method call, a new variable timer is created into which the new value from get_ticks is written

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question