from turtle import Turtle, Screen
from paddle import Paddle
from ball import Ball
screen = Screen()
screen.setup(width=800, height=600)
screen.bgcolor(“black”)
screen.title(“Octucode: Ping Pong”)
right_paddle = Paddle((350, 0))
left_paddle = Paddle((-350, 0))
ball = Ball()
screen.listen()
screen.onkey(right_paddle.move_up,“Up”)
screen.onkey(right_paddle.move_down,“Down”)
screen.onkey(left_paddle.move_up,“w”)
screen.onkey(left_paddle.move_down,“s”)
game_on = True
while game_on:
ball.goto(ball.xcor()+ball.x_move,ball.ycor()+ball.y_move)
if (ball.ycor() >= 280) or (ball.ycor() <= -280):
ball.y_move = -1
if (ball.xcor()>=330 and ball.distance(right_paddle)<=50) or (ball.xcor()<=-330 and ball.distance(left_paddle)<=50):
ball.x_move=-1
if ball.xcor()>330:
ball.goto(0,0)
ball.x_move*=-1
screen.exitonclick()
إعجاب واحد (1)
السطر 4 من النهايه خليه :
if ball.xcor()>330 or ball.xcor ()<-330
بدل :
if ball.xcor()>330: