I'm trying to use Turtle to make a ball bounce on the sides of a stadium-like surface. I have the right bouncing angles, but there's something wrong: sometimes, when the ball arrives against a rounded side, it doesn't directly bounce but it goes over the edges and continues for a while.
Here's the part of the program :
while nbrebonds>=0: #rebonds means bounce
forward(1)
if (xcor()<-150 and distance(-150,50)>100) or (xcor()>150 and distance(150,50)>100):
trajectoire=heading()
normale = towards(0,0) #direction de la normale
trajectoire = 2*normale-180-trajectoire
print(trajectoire) #trajectoire du rebond
setheading(trajectoire)
forward(1)
nbrebonds+=-1
print(nbrebonds)
if ycor()<-50 or ycor()>150:
trajectoire=heading()
trajectoire=360-trajectoire
setheading(trajectoire)
nbrebonds+=-1
print(nbrebonds)