import turtle, random
window = turtle.Screen()
border = turtle.Turtle()
border.pensize(5)
border.speed(0)
speed = 20
#Квадрат
border.up()
border.goto(300,300)
border.down()
border.goto(300,-300)
border.goto(-300,-300)
border.goto(-300,300)
border.goto(300,300)
border.hideturtle()
balls = []
count = 5
for i in range(count):
ball = turtle.Turtle()
ball.pensize(1)
ball.hideturtle()
ball.shape("circle")
ball.up()
randx = random.randint(-290,290)
randy = random.randint(-290,290)
red = random.random()
green = random.random()
blue = random.random()
ball.color(red,green,blue)
ball.goto(randx,randy)
ball.showturtle()
dx = random.randint(-5,5)
dy = random.randint(-5,5)
balls.append([balls,dx,dy])
for i in balls:
print(i)
while True:
for i in range(count):
balls[i]
x,y = balls[i][0].positions()
if x + balls[i][1] >= 300 or x + balls[i][1] <= -300:
balls[i][1] = -balls[i][1]
if y + balls[i][2] >= 300 or y + balls[i][2] <= -300:
balls[i][2] = -balls[i][2]
balls[i][0].goto(x+balls[i][1],y+balls[i][2])