title: Animating Pygame Rects to move up the Screen
body: <p>the endeavor is to draw clusters of rects [bubbles] moving up the screen at varying rates of speed. i've hit a roadblock when it comes to rendering the moving rects. </p>
  
  <p>the way i've gone about it thus far is to populate a list with class instances of  my Bubble class. from there i've iterated through the list of instances and called their blow_bubble method, effectively drawing each bubble at a different location on the screen and initializing each with its own value for its speed of movement. these bubbles are then appended to a separate list entitled "drawn", to signify that they have indeed been drawn (though not rendered).</p>
  
  <p>the next part is where it gets bumpy.</p>
  
  <p>i have a while loop that accepts the length of the drawn list being greater than zero as its condition for running. as per the form in this article: <a href="http://programarcadegames.com/index.php?chapter=introduction_to_animation" rel="nofollow noreferrer">http://programarcadegames.com/index.php?chapter=introduction_to_animation</a>
  the screen surface is set to fill at the beginning of the loop and at the end of it i've updated the screen surface via pygame.display.flip(). in the middle of the while loop i'm iterating through class instances in the drawn list and decrementing the attribute that represents their y value by the instance's attributed rate of movement. </p>
  
  <p>somehow this doesn't work. </p>
  
  <p>i've checked to make sure the y value is actually decrementing; in a print statement the output is what would be expected: the y value descends into the negative numbers. yet the rects remain drawn statically. </p>
  
  <p>as always, any insights are greatly appreciated.</p>
  
  <pre><code>#colors, screen, clock, etc defined above but omitted 
  pygame.init()
  
  class Bubble():
      def __init__(self, screenheight, screenwidth):
          self.w = self.h = 0 
          self.x,  self.y = 0, 0
          self.moverate = 0
  
      def reset_bubble(self):
          self.w = self.h = random.randrange(2, int(screenwidth*1/4))
          self.x = random.randrange(0, (screenwidth-self.w))
          self.y = screenheight-self.w
          self.moverate = 1
  
      def blow_bubble(self):
          self.reset_bubble()
          pygame.draw.rect(screen, WHITE, (self.x, self.y, self.w, self.h), 10)
  
  bubbles = []
  drawn = []
  i = 0
  
  for i in range(10):          #creates list of bubble objects
          bubble = Bubble(screenheight, screenwidth)
          bubbles.append(bubble)
  
  for i in range(len(bubbles)):      #draws bubbles without rendering them
      bubbles[i].blow_bubble()
      drawn.append(bubbles[i])       #appends objects to a new list (drawn)
  
  while len(drawn) &gt; 0:
      screen.fill((BLACK))
      drawn[i].y -= drawn[i].moverate     #moves the bubble up the screen
      pygame.display.flip()               #updates the screen
  
      if i &gt;= 0:    #counts up til len(drawn) then counts down [then up again]
          i+=1  #to make sure we move every bubble a little each iteration
      if i ==len(drawn):
          i-= 1
  clock.tick(FPS)
  pygame.quit()
  </code></pre>