Jump to content

Snakes Pygame: Difference between revisions

no edit summary
No edit summary
No edit summary
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.
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!
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.