title: Python 3.x tkinter - How can I duplicate the same sprite on the canvas in random locations?
body: <p>In my code (which will be at the end of the long description) I have made a tkinter canvas game. So far, the sprite on the canvas called "player" moves towards the mouse. When the sprite "player"'s coordinates are close enough to the sprite "food"'s coordinates then the food is deleted from the canvas and then created again in another random location. This also increases the size of the sprite "player" by 1 (by adding 1 to the x1 and y1 coordinates).</p>
  
  <p>But my issue is that without some very strange results I cannot seem to be able to create any more than 1 stable "food" sprite. Ideally I'd like to be able to duplicate infinitely until my CPU overheats... but I'll settle for 10 sprites (But then need to be identical). This is so that the "player" sprite has much more food to eat.</p>
  
  <pre><code>import random
  from tkinter import *
  import math
  import time
  
  class Cells():
  
      def __init__(self):
          #Variables
          self.master = Tk()
          self.canvas = Canvas(self.master, width=1000,height=800)
          self.canvas.pack()
          self.player_colours = ['blue','red','orange','green','purple','yellow']
          self.random_int = random.randint(0,5)
          self.random_colour = self.player_colours[self.random_int]
          self.random_food_int = random.randint(0,5)
          self.random_food_colour = self.player_colours[self.random_food_int]
          self.tick_intervals = 10
          #Coords
          self.x0 = 500
          self.y0 = 400
          self.x1 = 530 
          self.y1 = 430
          self.rx0 = random.randint(100,900)
          self.ry0 = random.randint(100,700)
          self.rx1 = self.rx0 + 20
          self.ry1 = self.ry0 + 20
          self.rx0_2 = random.randint(100,900)
          self.ry0_2 = random.randint(100,700)
          self.rx1_2 = self.rx0_2 + 20
          self.ry1_2 = self.ry0_2 + 20
          self.player_size = self.x1 - self.x0
          self.player_coords = [self.x0, ",", self.y0]
          #Sprites
          self.speed = (self.x0 - self.x1) / 10
          self.reverse = self.speed - self.speed - self.speed
          self.food = self.canvas.create_oval(self.rx0,self.ry0,self.rx1,self.ry1,fill=self.random_food_colour)
          self.player = self.canvas.create_oval(self.x0,self.y0,self.x1,self.y1, fill=self.random_colour)
          self.player_coords_text_x = self.canvas.create_text(50,10,text=self.x0)
          self.player_coords_text_y = self.canvas.create_text(100,10,text=self.y0)
          self.food_coords_text_x = self.canvas.create_text(50,10,text=self.rx0_2)
          self.food_coords_text_y = self.canvas.create_text(100,10,text=self.ry0_2)
          self.player_text = self.canvas.create_text(self.x0,self.y0,text=self.player_size)
          self.food_count = 1
          self.move()
          self.master.mainloop()
      def move(self):
          self.canvas.delete(self.player_coords_text_x)
          self.canvas.delete(self.player_coords_text_y)
          self.player_coords_text_x = self.canvas.create_text(50,10,text=self.x0)
          self.player_coords_text_y = self.canvas.create_text(100,10,text=self.y0)
  
          self.canvas.delete(self.food_coords_text_x)
          self.canvas.delete(self.food_coords_text_y)
          self.food_coords_text_x = self.canvas.create_text(50,50,text=self.rx0_2)
          self.food_coords_text_y = self.canvas.create_text(100,50,text=self.ry0_2)
  
  
          self.is_food = True
          #mouse variables
          x = self.canvas.winfo_pointerx()-self.canvas.winfo_rootx()
          y = self.canvas.winfo_pointery()-self.canvas.winfo_rooty()
          self.mousex0 = x - 10
          self.mousey0 = y - 10
          self.mousex1 = x + 10
          self.mousey1 = y + 10
          #sprite variables
          self.player_center_x = self.x0 + ((self.x1 - self.x0) / 3)
          self.player_center_y = self.y0 + ((self.x1 - self.x0) / 3)
  
          self.canvas.delete(self.player_text)
          self.player_text = self.canvas.create_text(self.player_center_x,self.player_center_y,text=self.player_size)
          #bounderies
          if self.player_center_x &lt; 20:
              self.x0 -=self.speed
              self.x1 -=self.speed
          elif self.player_center_x &gt; 980:
              self.x0 += self.speed
              self.x1 += self.speed
          if self.player_center_y &lt; 20:
              self.y0 -= self.speed
              self.y1 -= self.speed
          elif self.player_center_y &gt; 780:
              self.y0 += self.speed
              self.y1 += self.speed
          #following the mouse
          if self.player_center_x &lt; self.mousex0:
              self.x0 -= self.speed
              self.x1 -= self.speed
          elif self.player_center_x &gt; self.mousex0:
              self.x0 += self.speed
              self.x1 += self.speed
          if self.player_center_y &lt; self.mousey0:
              self.y0 -= self.speed
              self.y1 -= self.speed
          elif self.player_center_y &gt; self.mousey0:
              self.y0 += self.speed
              self.y1 += self.speed
          #eating the food
          if self.is_food == True:
              if self.x0 &lt; self.rx0 and (self.rx0 - self.x0) &lt;= self.player_size:
                  if self.y0 &lt; self.ry0 and (self.ry0 - self.y0) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
              if self.x0 &gt; self.rx0 and (self.x0 - self.rx0) &lt;= self.player_size:
                  if self.y0 &lt; self.ry0 and (self.ry0 - self.y0) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
              if self.x0 &gt; self.rx0 and (self.x0 - self.rx0) &lt;= self.player_size:
                  if self.y0 &gt; self.ry0 and (self.y0 - self.ry0) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
              if self.x0 &lt; self.rx0 and (self.rx0 - self.x0) &lt;= self.player_size:
                  if self.y0 &gt; self.ry0 and (self.y0 - self.ry0) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
          if self.is_food == True:
              if self.player_center_x &lt; self.rx0_2 and (self.rx0_2 - self.player_center_x) &lt;= self.player_size:
                  if self.player_center_y &lt; self.ry0_2 and (self.ry0_2 - self.player_center_y) &lt;= self.player_size:
                     self.canvas.delete(self.food)
                     self.player_size += 1
                     self.x1 += 1
                     self.y1 += 1
                      self.is_food = False
              elif self.player_center_x &gt; self.rx0_2 and (self.player_center_x - self.rx0_2) &lt;= self.player_size:
                 if self.player_center_y &lt; self.ry0_2 and (self.ry0_2 - self.player_center_y) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
              elif self.player_center_x &gt; self.rx0_2 and (self.player_center_x - self.rx0_2) &lt;= self.player_size:
                  if self.player_center_y &gt; self.ry0_2 and (self.ry0_2 + self.player_center_y) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
              elif self.player_center_x &lt; self.rx0_2 and (self.player_center_x + self.rx0_2) &lt;= self.player_size:
                  if self.player_center_y &gt; self.ry0_2 and (self.ry0_2 + self.player_center_y) &lt;= self.player_size:
                      self.canvas.delete(self.food)
                      self.player_size += 1
                      self.x1 += 1
                      self.y1 += 1
                      self.is_food = False
  
          if self.is_food == False:
              self.rx0_2 = random.randint(100,900)
              self.ry0_2 = random.randint(100,700)
              self.rx1_2 = self.rx0_2 + 20
              self.ry1_2 = self.ry0_2 + 20
              self.food = self.canvas.create_oval(self.rx0_2,self.ry0_2,self.rx1_2,self.ry1_2,fill=self.random_food_colour)
              self.is_food = True
  </code></pre>
  
  <p>This Guys is where my original idea for how to duplicate the same sprite comes from. But if you run it yourselves you will see that the results are... questionable.
  Please help me make this work guys.</p>
  
  <pre><code>        #if self.food_count &lt;= 10:
              #self.food = self.canvas.create_oval(self.rx0_2,self.ry0_2,self.rx1_2,self.ry1_2,fill=self.random_food_colour)
              #self.food_count += 1
  
          #loop
          self.canvas.coords(self.player,self.x0,self.y0,self.x1,self.y1)
          self.canvas.after(self.tick_intervals,self.move)
  if __name__ == '__main__':
      Cells()
  </code></pre>