title: pygame sprite sheet cutter is returning subsurface error, but size seems to be accurate
body: <p>So I have this image file I got from OpenGameArt.org <img src="https://i.stack.imgur.com/SsmWh.png" alt="enter image description here"></p>
  
  <p>It is 576 X 256 pixels, so I have this function to extract images from it:</p>
  
  <pre><code>def sprite_sheet_load(colorKey, spriteLocX, spriteLocY, spriteSizeX, spriteSizeY, fileName):
      '''Purpose: to extract a sprite from a sprite sheet at the chosen location'''
      '''credit to Stackover flow user hammyThePig for original code'''
  
      sheet = pygame.image.load(fileName).convert() #loads up the sprite sheet. convert makes sure the pixel format is coherent
      sheet.set_colorkey(colorKey) #sets the color key
  
      sprite = sheet.subsurface(pygame.Rect(spriteLocX, spriteLocY, spriteSizeX, spriteSizeY)) #grabs the sprite at this location
  
      return sprite
  </code></pre>
  
  <p>And within the Player class of my game, I have this code that calls up the above function in for loops</p>
  
  <pre><code>    playerImages = []   #lists for the player images
      playerDeathImages = [] # ""
  
      ###Image Gathering Section VVV ####
  
      spriteXLoc = 0 #starting x location for the sprite
      spriteYLoc = 0 #starting y location for the sprite
      spriteXSize = 64
      spriteYSize = 64
  
      #Grab the images for the main character's walking poses
  for y in range(0,9): #handle the columns of sprite sheet
      for x in range(0,4): #handle the rows of sprite sheet
                  playerImages.append(sprite_sheet_load(black, spriteXLoc, spriteYLoc, spriteXSize, spriteYSize, "mainCharacter.png"))
                  spriteXLoc += spriteXSize
      spriteXLoc = 0 #reset the inital x value
      spriteYLoc += spriteYSize #increment the y value
  </code></pre>
  
  <p>SpriteLocX gets to 576, the max length of the image, and by that point, it should reset and do the next row, but instead, I get a subsurface error stating that it went over, or more specifically:</p>
  
  <pre><code>    Traceback (most recent call last):
        File "game.py", line 97, in &lt;module&gt;
          player = Player() #create a player object
        File "game.py", line 63, in __init__
          playerImages.append(sprite_sheet_load(black, spriteXLoc, spriteYLoc, spriteXSize, spriteYSize, "mainCharacter.png"))
        File "game.py", line 33, in sprite_sheet_load
          sprite = sheet.subsurface(pygame.Rect(spriteLocX, spriteLocY, spriteSizeX, spriteSizeY)) #grabs the sprite at this location
      ValueError: subsurface rectangle outside surface area
  
              spriteXLoc = 0 #reset the inital x value
              spriteYLoc += spriteYSize #increment the y value
  </code></pre>
  
  <p>I've used this code before with no issue.  What is going wrong?  Also, is there a more accurate way to get the Spirte Size X and Y dimensions besides dividing the width and height by the number of columns and rows respectively?   </p>