Snakes Pygame: Difference between revisions

no edit summary
imported>Jesstess
imported>Jesstess
No edit summary
=== 3. Give the game a better background ===
 
The game has a pretty boring solid color background. Spice it up by adding a background image. We've provided a sample background fileimage callcalled <code>leaves.jpg</code> in the Snakes directory, but create and add your own if you want!
 
Use [http://www.pygame.org/docs/ref/image.html#pygame.image.load pygame.image.load] to load the background. You'll need to re-display the background on every tick of the game, just like we currently do with the solid color using <code>game_surface.fill(BACKGROUND_COLOR)</code>.
Test your changes by re-running the game and holding down the arrow key while moving your snake around.
 
=== 5. HandleMake quitthe andfood restartlook keymore pressesinteresting ===
 
Snake food is just a solid-colored square. Spice it up by using an image instead. We've provided a sample food image called <code>cherry.png</code> in the Snakes directory, but create and add your own if you want!
 
Currently, in the <code>Food</code> class <code>self.surface</code> is filled with a random color. Use [http://www.pygame.org/docs/ref/image.html#pygame.image.load pygame.image.load] to load and use the food image instead.
 
Test your changes by re-running the game and observing that your custom food image is used.
 
=== 6. Handle quit and restart key presses ===
 
I want to keep playing! So far, there's no way to quit (besides closing the window) or restart the game.
Anonymous user