I am working on project when two a powerup sprite collides with the player sprite, a +score displays on screen for 1-2 seconds. I can get the program working, but the score blips too fast.
#### Add Ammo Powerup ########
RandP_ammo = random.randrange(3, 20)
ammopwrUp = pygame.sprite.spritecollide(player, powerAmmo, True)
if totalBadGuys == RandP_ammo:
for i in range(1):
spawns = PowerUps(ammoUp)
allSprites.add(spawns)
powerAmmo.add(spawns)
if ammopwrUp:
totalAmmo += 25
addToScore = 15
score += addToScore
window.fill(BLUE)
ammoTime = pygame.time.get_ticks() + 500
print("start of ammoTime: " + str(ammoTime))
if ammoTime:
print(ammoTime)
levels(window, "+ " + str(addToScore), 15, HEIGHT / 2, WIDTH / 2 )
if ammoTime - last >= 1000:
print("New1:" + str(ammoTime))
ammoTime = None
last = pygame.time.get_ticks()
I am printing AmmoTime for dubugging, and levels function simply blits text to screen. The score update is shown, but I am not able to control the time it is shown on screen. Also, How can I show the score where the sprites collided instead of middle of screen as I have it now?