"rect" class can't be the parameterof the method "screen.blit()"
<p>I want to draw a rectangle to be a simplified rocket, but my <code>pycharm</code> shows <code>argument 1 must be pygame.Surface, not pygame.Rect</code> just like in the picture.<a href="http://i.stack.imgur.com/gk1MH.png" rel="nofollow"><img src="http://i.stack.imgur.com/gk1MH.png" alt="enter image description here"></a></p>

<p>the following is my code:</p>

<pre><code>screen = pygame.display.set_mode([400, 600])
screen.fill([0, 0, 0])
ship = pygame.draw.rect(screen, [255, 22, 150], [200, 400, 50, 100], 0)
moon = pygame.draw.rect(screen, [79, 200, 145], [0, 550, 400, 50], 0)
screen.blit(moon, [0, 500, 400, 100])
</code></pre>

<p>Then I changed my code to this:</p>

<pre><code>screen = pygame.display.set_mode([400, 600])
screen.fill([0, 0, 0])
ship_mode = pygame.draw.rect(screen, [255, 22, 150], [200, 400, 50, 100], 0)
ship = ship_mode.convert()
moon_mode = pygame.draw.rect(screen, [79, 200, 145], [0, 550, 400, 50], 0)
moon = moon_mode.convert()
screen.blit(moon, [0, 500, 400, 100])
</code></pre>

<p>This time it indicates <code>Traceback (most recent call last):
  File "E:/untitled/launching rocket.py", line 11, in &lt;module&gt;
    ship = ship_mode.convert()
AttributeError: 'pygame.Rect' object has no attribute 'convert'</code> 
How could I finish what I am expecting?</p>

<p>The function <code>pygame.draw.rect</code> draws directly on the Surface (the one you've given as argument) and returns a Rect object representing the area drawn. It doesn't return a Surface. </p>

<p>You can remove the line <code>screen.blit(moon, [0, 500, 400, 100])</code> since the rectangle is already drawn to the <code>screen</code>. You don't need to assign the function to anything either, unless you need a reference to where the rects were drawn.</p>

<pre><code>import pygame
pygame.init()

screen = pygame.display.set_mode([400, 600])
screen.fill([0, 0, 0])
pygame.draw.rect(screen, [255, 22, 150], [200, 400, 50, 100], 0)
pygame.draw.rect(screen, [79, 200, 145], [0, 550, 400, 50], 0)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    pygame.display.update()
</code></pre>

<p>If you want to move images around I suggest you do something like this:</p>

<pre><code>import pygame
pygame.init()

screen = pygame.display.set_mode([400, 600])

ship_image = pygame.Surface((50, 100))  # Create a rectangular Surface.
ship_image.fill((255, 22, 150))  # Fill it with a color.
ship_rect = pygame.Rect(200, 400, 50, 100)  # Create a rect for where to blit the ship.

moon_image = pygame.Surface((400, 50))  # Create a rectangular Surface.
moon_image.fill((79, 200, 145))  # Fill it with a color.
moon_rect = pygame.Rect(0, 550, 400, 50)  # Create a rect for where to blit the ship.


while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()
        elif event.type == pygame.KEYDOWN:  # If you press a key down.
            if event.key == pygame.K_RIGHT:  # If the key is the right arrow key.
                ship_rect.move_ip(5, 0)  # Move the rect to the right.
            elif event.key == pygame.K_LEFT:
                ship_rect.move_ip(-5, 0)
            elif event.key == pygame.K_UP:
                ship_rect.move_ip(0, -5)
            elif event.key == pygame.K_DOWN:
                ship_rect.move_ip(0, 5)

    # Cover up the screen with the background color.
    # This is to erase all images on the screen.
    # Try removing this line to see why we want to do so.
    screen.fill((0, 0, 0))

    screen.blit(ship_image, ship_rect)  # Blit the ship image at the position of the ship_rect.
    screen.blit(moon_image, moon_rect)  # Blit the moon image at the position of the moon_rect.

    pygame.display.update()  # Update the display so all changes are visable
</code></pre>

python python-2.7 pygame