title: nameError within Inheritance
body: <p>When the program is run I get this error:</p>
  
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    File "G:/assets/gametest1.py", line 141, in &lt;module&gt;
      cam = camera(318,0,220)
    File "G:/gametest1.py", line 85, in __init__
      super(camera,self).__init__(playerposX,characterPosX,y)
  NameError: name 'characterPosX' is not defined
  
  
  
  </code></pre>
  
  <p>The player class</p>
  
  <pre><code>class player:
      def __init__(self, playerposX,characterPosX,y):
          self.playerposX = playerposX
          self.y = y
          self.width = 88
          self.height = 135
          self.standing = True
          self.left = False
          self.right = True
          self.vel = 15
          self.jumping = False
          self.jumpCount = 10
          self.attacking = False
          self.characterPosX = characterPosX
  </code></pre>
  
  <p>Above is the The constructor code for the player class The aim of the code is to get the screen to scroll as the player moves eventually stopping when the map limit is reached</p>
  
  <pre><code>
      def move(self, playerposX, y):
          self.k = pygame.key.get_pressed()
          if self.k[pygame.K_LEFT] and self.playerposX &gt; 0 - 45:
              self.left = True
              self.right = False
              self.playerposX -= self.vel
              self.standing = False
          elif self.k[pygame.K_RIGHT] and self.playerposX &lt; 1500 - 90:
              self.right = True
              self.left = False
              self.standing = False
              self.playerposX += self.vel
          else:
              self.standing = True
  
      def jump(self, y):
          if not (self.jumping):  # checks if user's jumping intiating jump
              if self.k[pygame.K_SPACE]:
                  self.jumping = True
          else:
              if self.jumpCount &gt;= -10:
                  neg = 1
                  if self.jumpCount &lt; 0:
                      neg = -1
                  self.y -= (self.jumpCount ** 2) * 0.5 * neg
                  self.jumpCount -= 1
              else:
                  self.jumping = False
                  self.jumpCount = 10
  
      def draw(self, win):
          wLeft = pygame.image.load('runningleft.png')
          wRight = pygame.image.load('running.png')
          char = [pygame.image.load('idleright.png'), pygame.image.load('idleleft.png')]
          attack = [pygame.image.load('attackleft.png'), pygame.image.load('attackright.png')]
          if not (self.standing):
              if self.left:
                  win.blit(wLeft, (self.playerposX, self.y))
              elif self.right:
                  win.blit(wRight, (self.playerposX, self.y))
          else:
              if self.right:
                  win.blit(char[0], (self.playerposX, self.y))
              if self.left:
                  win.blit(char[1], (self.playerposX, self.y))
          if self.attacking == True:
              if self.left:
                  win.blit(attack[0], (self.playerposX, self.y))
              if self.right:
                  win.blit(attack[1], (self.playerposX, self.y))
  
  </code></pre>
  
  <p>The child class camera which I aimed to inherit attributes from the parent class(player). This is the code which I will be using to move the background as the player move forward or backward</p>
  
  <pre><code>class camera(player):
      def __init__(self, stagePosX,playerposX,y):
          super(camera,self).__init__(playerposX,characterPosX,y)
          self.playerposX = playerposX
          self.startscrolling = bgWidth / 2
          self.stagePosX = stagePosX
          self.rel_x = 0
  
  
      def scroll(self,stagePosX):
          if self.k[pygame.K_LEFT]:
              self.vel = (self.vel*-1)
          elif self.k[pygame.K_RIGHT]:
              self.vel = (self.vel*1)
          else:
              self.vel = 0
  
  
  
          self.rel_x = self.stagePosX % bgWidth
          if self.playerPosX &gt; stageWidth - self.width:
              self.playerPosX = self.stageWidth - self.width  # If the player position exceeds the stage
          if self.playerposX &lt; 0 - self.width:
              self.playerposX = self.width  # If the player position is far left
          if self.playerposX &lt; self.startscrolling:
              self.characterPosX = self.playerposX
          elif self.playerposXplayerposX &gt; stageWidth - self.startscrolling:
              self.characterPosX = self.playerPosX - stageWidth + self.width
          else:
              self.characterPosX = self.startscrolling
              self.stagePosX +=  -self.vel
  
  
  
  
  
  
      def draw(self, win):
          win.blit(bg, (self.rel_x - bgWidth, 0))
          if self.rel_x &lt; bgWidth:
              win.blit(bg, (self.rel_x, 0))
  </code></pre>