title: Python Turtle collision border collision not working
body: <p>I'm trying to get my turtle object to turn 180 degrees when it comes into contact with the border however this doesn't happen. Rather than i want to use and if statement saying if the x and y cor's are higher or lower than a certain amount they will cause the object to move back. Here is the code bellow.</p>
  
  <pre><code>from turtle import *
  import turtle
  
  title("Pokemon: Fire Red")
  t = turtle.Turtle()
  screen = t.getscreen()
  
  t.penup()
  
  
  t.left(90)
  
  border = turtle.Turtle()
  border.up()
  border.setposition(-240, 160)
  border.down()
  border.pensize(3)
  for side in range(2):
      border.forward(480)
      border.right(90)
      border.forward(320)
      border.right(90)
  
  tx, ty = t.pos()
  if tx &lt; -240 or tx &gt; 240 or ty &lt; -160 or ty &gt; 160:
      t.hide()
  
  
  
  
  Screen()
  
  showturtle()
  
  
  
  def k1():
      t.forward(50)
  
  
  
  def k2():
      t.left(90)
      t.forward(50)
  
      t.right(90)
  
  def k3():
      t.right(90)
      t.forward(50)
  
      t.left(90)
  
  def k4():
      t.forward(-50)
  
  
  
  
  
  onkey(k1, "Up")
  onkey(k2, "Left")
  onkey(k3, "Right")
  onkey(k4, "Down")
  
  
  listen()
  mainloop()
  </code></pre>
  
  <p>Any help would be appreciated, thanks.</p>