0

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?

  • use `get_ticks` to control how long text is displayed. – furas Jan 31 '16 at 16:05
  • you can get `sprite` position and use it with displayed text. – furas Jan 31 '16 at 16:09
  • I do have `get_ticks` in the program, but it makes no difference. I'll try the `get sprite`. – nocturnal33 Jan 31 '16 at 20:03
  • `get sprite` has nothing to do with `time` but `get_tick` has. Maybe you should put part of this code in different place - but seeing only this part of code I don't know how all your code works. – furas Jan 31 '16 at 21:17

0 Answers0