Snakes Pygame: Difference between revisions

Content added Content deleted
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
Line 71: Line 71:


Test your changes by re-running the game, running into the bad snake to end the game, and making sure you can restart.
Test your changes by re-running the game, running into the bad snake to end the game, and making sure you can restart.


==Bonus exercises==

=== 1. Play a sound when you eat food ===

We've included <code>ding.ogg</code> as a sample sound, but find and add your own if you want!

Test your changes by re-running the game with the sound on and observing that a noise is played when the snake eats pieces of food.

=== 2. Give yourself multiple lives ===

Typically in games you have multiple lives available. Give your snake 3 lives to start with, lose a life each time you run into yourself or the bad snake, and display how many lives remain in the upper left corner.

You may find it convenient to create a new file with a new class called <code>Lives</code> that keeps track of this game state and the work of updating the display.


===Congratulations!===

You've read, modified, and improved a game using Pygame that uses images and sound and game concepts like an event loop and managing keypresses. Keep practicing!

[[File:Fireworks.png|150px]]
[[File:Balloons.png|150px]]