0

Tried putting it as a range but says that two operations cannot be done.

Check for collisions with barrier

if (head.ycor()<200 and head.ycor()>-200 and head.xcor()<10 and head.xcor()>-10):
    time.sleep(1)
    head.goto(-70, 0)
    head.direction = "stop"
    head.clear()

# Barrier
barrier = turtle.Turtle()
barrier.shape("square")
barrier.color("yellow")
barrier.speed(0)
barrier.goto(0, 0)
barrier.shapesize(stretch_len=1, stretch_wid=20)
barrier.penup()
  • Putting as a range what? Which two operations? What are you trying to do? What is happening instead? I't not very clear from your question, please try to clarify it. – Papooch Apr 11 '20 at 14:06
  • basically the snake goes through the barrier(code shown above), so in order for the snake to die, I tried two methods but none worked(I'm a beginner). The two methods are: # Check for collisions with barrier if head.direction(ycor(range(-200, 200) and head.direction(xcor(range(-10, 10))))): time.sleep(1) head.goto(-70, 0) head.direction = "stop" head.clear() and the other one is shown above. Thanks. – md samin ibne amin Apr 12 '20 at 07:41
  • I see. Your problem is that you are checking for the opposite condition. You have to check if `head.ycor() > 200 *OR* head.ycor() – Papooch Apr 12 '20 at 08:36

0 Answers0