console based pong in python

main.py
import os
import time

def print_paddle(paddle1, paddle2):
    for i in range(20):
        if i >= paddle1 and i < paddle1 + 4:
            print('|', end='')
        else:
            print(' ', end='')

        print(' ' * 50, end='')

        if i >= paddle2 and i < paddle2 + 4:
            print('|')
        else:
            print('')

def print_ball(x, y):
    print(' ' * (x + 1) + 'o' + ' ' * (50 - x))
    for i in range(y):
        print()

paddle1 = 8
paddle2 = 8
ball_x = 25
ball_y = 10
ball_vx = -1
ball_vy = 1

while True:
    os.system('clear')
    print_paddle(paddle1, paddle2)
    print_ball(int(ball_x), int(ball_y))

    ball_x += ball_vx
    ball_y += ball_vy

    if ball_y == 0 or ball_y == 19:
        ball_vy *= -1

    if ball_x == 2:
        if ball_y >= paddle1 and ball_y < paddle1 + 4:
            ball_vx *= -1
        else:
            break

    if ball_x == 48:
        if ball_y >= paddle2 and ball_y < paddle2 + 4:
            ball_vx *= -1
        else:
            break

    time.sleep(0.05)

    if paddle1 > ball_y and paddle1 > 0:
        paddle1 -= 1
    elif paddle1 < ball_y and paddle1 < 16:
        paddle1 += 1

    if paddle2 > ball_y and paddle2 > 0:
        paddle2 -= 1
    elif paddle2 < ball_y and paddle2 < 16:
        paddle2 += 1
1289 chars
64 lines

gistlibby LogSnag