/
AndyKaos
/
HomeWork---Python---Task1
Обзор
Документация
Войти
/
AndyKaos
/
HomeWork---Python---Task1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
pong/pong.py
78 строк
2 KB
Андрей Кляус
create pong/pong.py
19 янв 2026, 18:54
Верифицирован
19 янв 2026, 18:54
b1c38f3
Код
Авторство
О чём код?
from turtle import * from random import * # -------------------------------- # конфиг канвы # -------------------------------- scr = Screen() scr.listen() canvas = scr.getcanvas() root = canvas.winfo_toplevel() scr.setup(600, 400) scr.title('Ping-Pong') scr.cv._rootwindow.resizable(False, False) # tracer(n=0, delay=100) # -------------------------------- # -------------------------------- # конфиг шарика # -------------------------------- ball = Turtle() ball.left(135) ball.speed = 10 ball.shape("circle") # -------------------------------- l1=[0,0] # -------------------------------- # конфиг палки # -------------------------------- stick_player = Turtle() stick_player.resizemode('user') stick_player.left(90) stick_player.shapesize(1, 4) stick_player.color("green") stick_player.shape("square") stick_player.speed(0) stick_player.penup() stick_player.goto(-275,0) def move_forward(): stick_player.forward(10) def move_backward(): stick_player.backward(10) scr.onkeypress(move_forward, "Up") scr.onkeypress(move_backward, "Down") # -------------------------------- # while True: # # def ball_movement(): # if ball.position()[1] <= 200 and ball.position()[1] >= -200: # angle = randint(15, 30) # ball.forward(2) # else: # ball.left(angle) # ball.forward(1) # if ball.position()[0] >= 280 and ball.position()[0] <= -280: # ball.home() # l1.append(ball.position()[0]) # l1.append(ball.position()[1]) # scr.title(l1) # l1.clear() # while True: # ball_movement() scr.mainloop()