Game Development:
Intro to Computer Science

CSC 105
Union College
Fall 2009

Exercises about dictionaries and to practice for the final are on Codelab.

Helpdesk in Olin 102, Sun-Thu 7-9pm.

Keeping track of scores

Solution.

Download the following pygame program: high_score_v0.py. And play it. You also need the following image and sound files: red_balloon.gif, green_balloon.gif, pop.wav.

Play this game and familiarize yourself with the code.

The goal for this exercise is to maintain a file of high scores. Whenever a new game is started the player is asked for his/her name. When the game is over, this players score is compared to the list of high scores read from a file. If the current score is greater than the smallest score in that file, the current score is either added to the file (if the file contains fewer than five high scores) or the smallest score is replaced by the current score.

The list of the five highest scores should be shown in the top left corner underneath the players current score, while he/she is playing. Like this:

Download this file: hiscores.txt. That's what our file of high scores is going to look like.

Now, plan our your implementation similar to what I did for the "Game of Life". Write down the desired functionality, what central data structures you are going to use, and how you can break the problem into steps.

Next