title: Referencing in Pygame
body: <p>Using a guide to help me produce a pygame platformer game, I have come across a coding concept that baffles me, in relation to my code, that is.</p>
  
  <p><a href="https://youtu.be/G8pYfkIajE8?t=4m1s" rel="nofollow noreferrer">https://youtu.be/G8pYfkIajE8?t=4m1s</a></p>
  
  <p>In this tutorial, he talks about creating a 'reference' so that the class recognises objects that have already been created.</p>
  
  <p>The sprite groups in one file would therefore be able to be recognised in another.</p>
  
  <p>In my code, I need to add the bullet sprite, which is created in the 'PlayerClass' file, into the sprite group, which is located in the 'base' file.</p>
  
  <p>My bullet object is called by this code (from a third file GameClass):</p>
  
  <pre><code>def shoot(self):
      print('Pew pew')
  
      bullet=Bullet.movebullet(self)
  </code></pre>
  
  <p>The following code is referenced in the above line Bullet.movebullet(self)</p>
  
  <pre><code>class Bullet(pygame.sprite.Sprite):
  
      def __init__(self,speed,Game):
          self.speed=speed
          self.image=pygame.Surface((10,10))
          self.rect=self.image.get_rect()
  
      def movebullet(self):
          self.rect.center=((self.x+self.speed),self.y)
          print('pew spew again')
  </code></pre>
  
  <p>The sprite groups are defined in my games class, located in the GameClass file.</p>
  
  <pre><code>class Game:
      def __init__(self):
          pass
  
      def run(self):
          sprites=pygame.sprite.Group()
          platforms=pygame.sprite.Group()
          ground=GameClass.Platform(0,700,1920,80,BLACK)
          middlewall=GameClass.Platform(500,600,30,100,BLACK)
  
          platforms.add(ground)
          platforms.add(middlewall)
  
          platforms.draw(display)
  
          player1=PlayerClasses.Player('Spy',1.5,5,5,200,200)
          sprites.add(player1)
  
          return sprites,platforms,player1
  </code></pre>
  
  <p>How would I reference the groups created in the Game class in the bullet file?</p>