I want to spawn an enemy every (some number) seconds, say 5.
I could do:
start_time = pygame.time.get_ticks()
if pygame.time.get_ticks() - start_time >= (some number):
spawn_enemy()
But there's one problem with that: when I change the FPS (clock.tick()
) from 120 to say 60 then the enemy spawn rate will remain the same.
I could also just make a variable:
var = 0
while True:
var += 1
if var >= (some number):
spawn_enemy()
But that seems like bad practice to me.