Exemplo n.º 1
0
        player1_rect = player1.draw(screen, WHITE)
        player2_rect = player2.draw(screen, WHITE)
        player1.move_player(keys, 1, height)
        player2.move_player(keys, 2, height)

        ball.draw(screen, color)
        ball.move_ball(height)

        wall_top.draw(screen, WHITE)
        wall_bottom.draw(screen, WHITE)

        vertical_line.draw(screen, WHITE)

        #------------------ COLISOES ------------------------------------------------

        ball.collide(player1_rect, player2_rect)

        #----------------- GERAR BOLA(QUANDO FAZ PONTO OU INICIA O JOGO) ------------

        if (win == 0):
            if (ball.x > width):
                ball.x = width / 2 + (randint(20, 50))
                ball.y = randint(90, 100)
                ball.speed_x *= -1
                point_sound = pygame.mixer.Sound('sounds/pong_point.wav')
                point_sound.play()
                pp1 += 1

            elif (ball.x < 0):
                ball.x = width / 2
                ball.y = randint(90, 100)