title: Get coordinates of "treasure" (turtles) in Maze Game that uses Python tkinter and turtle
body: <p>I am using Python 3 to make a maze using tkinter and turtle graphics. Most of the code works, except I cannot figure out how to "destroy" the "gold" in the game. Specifically, calling <code>player.collision()</code>, it says <code>Question object has no attribute xcor</code> even though I got this from a tutorial about a turtle Python maze game. I figured it would work the same as it did in that context, but with tkinter, everything seems to change. The problem occurs under <code>player.collision()</code> and the <code>while</code> loop at the end. Those are the two sections of code that are meant to "destroy," or hide, the "gold" turtles. I have included (almost) my entire code so everyone can see what is going on.</p>
  
  <p>(In addition to this question, I would like to create a way to move the player using the arrow keys rather than the buttons on the frame, but I can't figure out how.)</p>
  
  <p>I have tried naming the turtle specifically rather than just "other" in the <code>collision()</code> function. I have also tried making new methods under the <code>Question</code> class to "getX" and "getY" by returning <code>tur3.xcor()</code> and <code>tur3.ycor()</code> respectively. But this did not do anything except give me another error. Like I said, this code WORKED when it was just a turtle maze, but since adding tkinter, I have had to change a whole bunch of things.</p>
  
  <pre><code>import turtle
  import tkinter
  import math
  
  # Create window and canvas using tkinter.
  root = tkinter.Tk()
  root.title("Language Labyrinth")
  cv = tkinter.Canvas(root, width=600, height=600)
  cv.pack()
  
  # Create frame where button(s) will be.
  frame = tkinter.Frame(root)
  frame.pack()
  
  # Create Pen class to draw the maze.
  class Pen():
      def __init__(self):
          global tur
          global screen
          tur = turtle.RawTurtle(cv)
          screen = tur.getscreen()
          tur.shape("square")
          tur.color("white")
          screen.bgcolor("black")
          tur.penup()
          tur.speed(0)
  
  # Create setup so the maze will be drawn.
      def setup(self, level):
          global tur, walls
          for y in range(len(level)):
              for x in range(len(level[y])):
                  char = level[y][x]
  
                  screenx = -288 + (x * 24)
                  screeny = 288 - (y * 24)
  
                  if char == "X":
                      tur.goto(screenx, screeny)
                      tur.stamp()
  
                      walls.append((screenx, screeny))
  
  # Create player class to have a player.
  class Player():
      def __init__(self):
          global tur2
          tur2 = turtle.RawTurtle(cv)
          tur2.shape("square")
          tur2.color("blue")
          tur2.penup()
          tur2.speed(0)
  
  # Create setup to create the player on the screen.
      def setup2(self, level):
          global tur2
          for y in range(len(level)):
              for x in range(len(level[y])):
                  char = level[y][x]
  
                  screenx = -288 + (x * 24)
                  screeny = 288 - (y * 24)
  
                  if char == "P":
                      tur2.goto(screenx, screeny)
  
  # Define a function that will allow player to move up.
      def up(self):
          global tur2, walls
          # Calculate the spot to move to.
          movetoX = tur2.xcor()
          movetoY = tur2.ycor() + 24
  
          # Check if the space has a wall.
          if (movetoX, movetoY) not in walls:
              tur2.goto(movetoX, movetoY)
  
  # Define a function that will allow player to move down.
      def down(self):
          global tur2, walls
          # Calculate the spot to move to.
          movetoX = tur2.xcor()
          movetoY = tur2.ycor() - 24
  
          # Check if the space has a wall.
          if (movetoX, movetoY) not in walls:
              tur2.goto(movetoX, movetoY)
  
  # Define a function that will allow player to move left.
      def left(self):
          global tur2, walls
          # Calculate the spot to move to.
          movetoX = tur2.xcor() - 24
          movetoY = tur2.ycor()
  
          # Check if the space has a wall.
          if (movetoX, movetoY) not in walls:
              tur2.goto(movetoX, movetoY)
  
  # Define a function that will allow player to move right.
      def right(self):
          global tur2, walls
          # Calculate the spot to move to.
          movetoX = tur2.xcor() + 24
          movetoY = tur2.ycor()
  
          # Check if the space has a wall.
          if (movetoX, movetoY) not in walls:
              tur2.goto(movetoX, movetoY)
  
  # Check if player touches the question.
      def collision(self, other):
          global tur2
          a = tur2.xcor() - other.xcor()
          b = tur2.ycor() - other.ycor()
          distance = math.sqrt((a ** 2) + (b ** 2))
  
          if distance &lt; 5:
              return True
          else:
              return False
  
  # Create Question class to create the "gold" in the game.
  class Question():
      def __init__(self, x, y):
          global tur3
          tur3 = turtle.RawTurtle(cv)
          tur3.shape("circle")
          tur3.color("gold")
          tur3.penup()
          tur3.speed(0)
          tur3.goto(x, y)
  
      # Define function that will remove gold when collided with.
      def destroy(self):
          global tur3
          tur3.goto(2000, 2000)
          tur3.hideturtle()
  
  # Create a levels list.
  levels = [""]
  
  # Define first level.
  level_1 = [
  "XXXXXXXXXXXXXXXXXXXXXXXXX",
  "XP XXXXXXX          XXXXX",
  "X  XXXXXXX  XXXXXX  XXXXX",
  "X       XX  XXXXXX  XXXXX",
  "X       XX  XXX        XX",
  "XXXXXX  XX  XXX   Q    XX",
  "XXXXXX  XX  XXXXXX  XXXXX",
  "XXXXXX  XX    XXXX  XXXXX",
  "X  XXX Q      XXXX  XXXXX",
  "X  XXX  XXXXXXXXXXXXXXXXX",
  "X         XXXXXXXXXXXXXXX",
  "X     Q          XXXXXXXX",
  "XXXXXXXXXXXX     XXXXX  X",
  "XXXXXXXXXXXXXXX  XXXXX  X",
  "XXX  XXXXXXXXXX         X",
  "XXX               Q     X",
  "XXX         XXXXXXXXXXXXX",
  "XXXXXXXXXX  XXXXXXXXXXXXX",
  "XXXXXXXXXX              X",
  "XX   XXXXX        Q     X",
  "XX   XXXXXXXXXXXXX  XXXXX",
  "XX    XXXXXXXXXXXX  XXXXX",
  "XX    Q     XXXX        X",
  "XXXX                    X",
  "XXXXXXXXXXXXXXXXXXXXXXXXX"
  ]
  
  # Add questions list.
  questions = []
  
  # Add the level(s) to the levels list.
  levels.append(level_1)
  
  # Class instances.
  pen = Pen()
  player = Player()
  
  # Wall coordinate list.
  walls = []
  
  # Define function to setup the "gold" in the game.
  def setup3(level):
      for y in range(len(level)):
          for x in range(len(level[y])):
              char = level[y][x]
  
              screenx = -288 + (x * 24)
              screeny = 288 - (y * 24)
  
              if char == "Q":
                  questions.append(Question(screenx, screeny))
  
  #screen.onkeypress(player.up, "Up")
  #screen.onkeypress(player.down, "Down")
  #screen.onkeypress(player.left, "Left")
  #screen.onkeypress(player.right, "Right")
  
  # Creation of buttons that will allow player to move. (BIND ARROWS W/O BUTTONS??)
  up = tkinter.Button(frame, text="Up", command=player.up)
  up.bind("&lt;Up&gt;", player.up)
  up.pack()
  down = tkinter.Button(frame, text="Down", command=player.down)
  down.bind("&lt;Down&gt;", player.down)
  down.pack()
  left = tkinter.Button(frame, text="Left", command=player.left)
  left.bind("&lt;Left&gt;", player.left)
  left.pack()
  right = tkinter.Button(frame, text="Right", command=player.right)
  right.bind("&lt;Right&gt;", player.right)
  right.pack()
  
  # Define a function for the quit button.
  def quitPlaying():
      root.destroy()
      root.quit()
  
  # Creation of quit button.
  quitButton = tkinter.Button(frame, text="Quit", command=quitPlaying)
  quitButton.pack()
  
  # Game loop in regards to the gold. (Needs debugging)
  while True:
      # Check for player collision with a question.
      # Iterate through the questions list.
      for question in questions:
          if player.collision(question):
              # Destroy the question.
              question.destroy()
              # Remove question from questions list.
              questions.remove(question)
  
      # Update screen.
      screen.update()
  
  # Call main game loop.
  tkinter.mainloop()
  </code></pre>
  
  <p>Basically, I expect that when I move over the "gold" turtles, I want them to disappear as if I've collected them.</p>
  
  <p>(And for the movement, I would expect to use the arrow keys for movement instead of the buttons, but again, this is a secondary thing.)</p>