Nauč se Python > Kurzy > Beginners course PyLadies > Final project I. > Coding game: Pong

Coding game: Pong – Řešení [5]

import random
...
def reset():
    ball_coordinates[0] = WIDTH // 2
    ball_coordinates[1] = HEIGHT // 2

    # x speed - right or left
    if random.randint(0, 1):
        ball_speed[0] = SPEED
    else:
        ball_speed[0] = -SPEED
    # y speed - completely random
    ball_speed[1] = random.uniform(-1, 1) * SPEED
...
# We will set the initial state.
reset()

Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.