It moves but stops after it hits one of the walls when I write this function below:
Expand|Select|Wrap|Line Numbers
- def move_ball(heading):
- t1=turtle.Pen()
- t1.color("yellow")
- t1.shape("circle")
- x,y=turtle.position()
- while 200 > (t1.xcor()) >-200 and -90< (t1.ycor())<90:
- t1.forward(1)
- t1.setheading(heading)
Expand|Select|Wrap|Line Numbers
- # here I try to do all restrictions of 4 walls
- # just 2 walls here
- def wall_bottom(heading):
- t1=turtle.Pen()
- t1.color("yellow")
- t1.shape("circle")
- current=0
- if 100<t1.ycor()<-100:
- if 270 < t1.setheading() < 360:
- t1.forward(1)
- t1.setheading(0+(360-(t1.heading())))
- else:
- t1.forward(1)
- t1.setheading(180-(t1.heading()-180))
- def wall_top(heading):
- t1=turtle.Pen()
- t1.color("yellow")
- t1.shape("circle")
- if 200> t1.xcor() >-200:
- if 90> t1.setheading()<0:
- t1.forward(1)
- t1.setheading(0-(180-(t1.heading())))
- else:
- t1.forward(1)
- t1.setheading(180-(t1.heading()-180))