day 21 - pong WIP

This commit is contained in:
Tanguy Deleplanque
2025-07-15 17:43:03 +02:00
parent 6857990be5
commit 670508261b
4 changed files with 115 additions and 0 deletions

27
021/ball.py Normal file
View File

@ -0,0 +1,27 @@
from turtle import Turtle
import random
class Ball(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.color("white")
self.pu()
self.angle = random.randint(0,45)
self.angle = 50
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 = -self.angle
self.setheading(self.angle)