title: Tron Game Collision - Turtle Python
body: <p>I am trying to make a tron game where its a local 2 player. My code is below but it is an unfinished product. I wanted to know how I can make it so if the shape enemy  and the shape player touch each other or the line that they have created, it results to an outcome. Like printing Game Over and changing the background.
  I keep getting the errors written in my comments below.</p>
  
  <pre><code>def up():
      player.fd(15)
  def right():
      player.fd(15)
  def left():
      player.fd(15)
  def down():
      player.fd(15)
  
  playerPath = [[[100],[100]]]
  enemyPath = [[[600],[600]]]
  previousMove = "na"
  
  #I keep getting this error: TclError: bad event type or keysym "up"
  
  if previousMove != "up":
          #Check for other methods
      if previousMove == right():
          playerPath.append((playerPath[0][0][0] + 90, playerPath[0][0][1]))
      if previousMove == left():
          playerPath.append((playerPath[0][0][0] - 90, playerPath[0][0][1]))
      if previousMove == down():
          playerPath.append((playerPath[0][0][0] + 180, playerPath[0][0][1]))
          #repeat for other directions
  if previousMove == "up":
      playerPath[0][0].append(playerPath[0][0][0] + 30)
      playerPath[0][1].append(playerPath[0][1][0] + 30)
  previousMove = "up"
  
  
  if previousMove != "right":
          #Check for other methods
      if previousMove == up():
          playerPath.append((playerPath[0][0][0] - 90, playerPath[0][0][1]))
      if previousMove == left():
          playerPath.append((playerPath[0][0][0] + 180, playerPath[0][0][1]))
      if  previousMove ==down():
          playerPath.append((playerPath[0][0][0] + 90, playerPath[0][0][1]))
         #repeat for other directions
  if previousMove == "right":
      playerPath[0][0].append(playerPath[0][0][0] + 30)
      playerPath[0][1].append(playerPath[0][1][0] + 30)
  previousMove = "right"
  
  
  if previousMove != "left":
      #Check for other methods
      if previousMove == up():
          playerPath.append((playerPath[0][0][0] + 90, playerPath[0][0][1]))
      if previousMove == right():
          playerPath.append((playerPath[0][0][0] + 180, playerPath[0][0][1]))
      if previousMove == down():
          playerPath.append((playerPath[0][0][0] - 90, playerPath[0][0][1]))
          #repeat for other directions
  if previousMove == "left":
      playerPath[0][0].append(playerPath[0][0][0] + 30)
      playerPath[0][1].append(playerPath[0][1][0] + 30)
  previousMove = "left"
  
  
  if previousMove != "down":
          #Check for other methods
      if previousMove == up():
          playerPath.append((playerPath[0][0][0] + 180, playerPath[0][0][1]))
      if previousMove == left():
          playerPath.append((playerPath[0][0][0] + 90, playerPath[0][0][1]))
      if previousMove == right():
          playerPath.append((playerPath[0][0][0] - 90, playerPath[0][0][1]))
          #repeat for other directions
  if previousMove == "down":
      playerPath[0][0].append(playerPath[0][0][0] + 30)
      playerPath[0][1].append(playerPath[0][1][0] + 30)
  previousMove = "down"
  
  #This code gives me this error: IndexError: list index out of range    
  #for subPath in enemyPath:
  #    if player.position()[0] in range(subPath[0][0], subPath[0][1]) and player.position()[1] in range(subPath[1][0], subPath[1][1]):
  #        print("Collision")
  
  
  onkey(up, "up")
  onkey(left, "left")
  onkey(right, "right")
  onkey(down, "down")
  
  onkey(up1, "w")
  onkey(left1, "a")
  onkey(right1, "d")
  
  listen()
  mainloop()  
  </code></pre>