Ejemplo n.º 1
0
    player1.jumping()

    #shooting
    if pressed[pygame.K_SPACE]:
        if len(balls) <= 4 and player1.okShooting:
            balls.append(
                Ball(round(player1.x), round(player1.y), player1.lastDirection,
                     8, (10, 10, 10), 7))
        player1.okShooting = False

    if not pressed[pygame.K_SPACE]:
        player1.okShooting = True

    for k in balls:
        #let shoot ball moves and remove them out of screen
        if k.x >= 0 and k.x <= 1200:
            k.move()
        else:
            balls.remove(k)

        ballRect = pygame.Rect(k.x - k.radius, k.y - k.radius, k.radius * 2,
                               k.radius * 2)
        if zombieRect.colliderect(ballRect):
            balls.remove(k)
            zombie1.life -= 1

    zombie1.turnAround()
    draw()

    clock.tick(60)  #framerate