title: How can I attach an image to these rectangles in pygame?
body: <p>I have a functioning game like frogger, but it is only rectangles and squares currently. I was wondering if there was a way to simply "skin" the rectangles with an image instead of an RGB color.</p>
  
  <pre><code>import random
  import pygame
  from pygame.locals import *
  
  class Rectangle:
  
      def __init__(self, x, y, w, h):
          self.x = x
          self.y = y
          self.w = w
          self.h = h
  class Frog(Rectangle):
  
      def __init__(self, x, y, w):
          super(Frog, self).__init__(x, y, w, w)
          self.x0 = x
          self.y0 = y
          self.color = (34, 177, 76)
          self.attached = None
  
      def reset(self):
          self.x = self.x0
          self.y = self.y0
          self.attach(None)
  
      def move(self, xdir, ydir):
          self.x += xdir * g_vars['grid']
          self.y += ydir * g_vars['grid']
  
      def attach(self, obstacle): 
          self.attached = obstacle
  
      def update(self):
          if self.attached is not None:
              self.x += self.attached.speed
  
          if self.x + self.w &gt; g_vars['width']:
              self.x = g_vars['width'] - self.w
  
          if self.x &lt; 0:
              self.x = 0
          if self.y + self.h &gt; g_vars['width']:
              self.y = g_vars['width'] - self.w
          if self.y &lt; 0:
              self.y = 0
  
      def draw(self):
          rect = Rect( [self.x, self.y], [self.w, self.h] )
          pygame.draw.rect( g_vars['window'], self.color, rect )
  </code></pre>