day 22 (actually, there's no 21) - finished Pong

This commit is contained in:
Tanguy Deleplanque
2025-07-16 12:47:31 +02:00
parent 670508261b
commit 697d53f836
5 changed files with 52 additions and 9 deletions

28
022/ball.py Normal file
View File

@ -0,0 +1,28 @@
from turtle import Turtle
import random
class Ball(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.color("white")
self.speed("fastest")
self.pu()
self.move_speed = 0.1
self.angle = random.randint(0,45)
self.setheading(self.angle)
print(self.angle)
def move(self):
self.forward(20)
def bounce_wall(self):
self.angle = -self.angle
self.setheading(self.angle)
def bounce_paddle(self):
self.angle = 180 - self.angle
self.setheading(self.angle)