Assigned Date: Friday, Mar. 13, 2015
Due Date: Monday, Mar. 23, 2015
Due Time: 12:20pm
Last modified on March 20, 2015, at 12:29 PM (see updates)
Write a program that simulates a game of cat and mouse. Your program should animate a picture of a cat using the arrow keys, and a picture of a mouse using (what else?) the mouse (or a touchpad).
This is a pair-programming assignment (you may work with one partner if you wish).
The goal of the game is for the cat player to capture the mouse, and for the mouse player to evade capture.
- To learn the fundamentals of procedural analysis and design.
- To learn the features of procedural programming: the major types of statements, such as assignment, repetition, and the major data types, such as integers, real numbers, and character strings.
Input and Output
The input to the program will be the cat speed (e.g., 1, 5, or 10). This determines how many pixels the cat moves for each press of the arrow keys.
Game goes on while mouse can evade cat. Game ends when cat captures mouse (hint - use Widget
Score gets incremented for each pixel the mouse moves (pays to keep moving).
When game over, display a Game Over message.
The output of the program should be graphical, using the gui library, and potentially these images:
It is OK to use your own (other) images.
Consider adding sounds, etc.
Whatever you do, focus on making your game more fun to play.
Make sure your header documentation clearly describes all game features.
In general, you should comment any variable, obscure statement, block of code, etc. you create.
Your comments should reflect the "why" something is there (or being done), as opposed to the "how". The "how" is reflected in the code. The "why" usually comes from the thought you had, as to what you were trying to do, before you wrote the corresponding Python code.
So, since that info is in your head first (i.e., before you write the code), it is much easier to type it in your program (before you figure out the corresponding code that does what needs to be done).
Conversely, once you have already written the code, it is very hard to go back and recreate the original thought (thus comments written after the code tend to focus on the "how" something is being done, and not the "why" - the latter being what we need.)
The goal of comments is to gently introduce someone accurately into the big picture of our code - the forest view - while the code itself represents the tree view.
Additionally, your code should always have header documentation that explains what the program does, in general terms.
Follow the documentation instructions from Homework 1.
You will submit your assignment via OAKS. Your submission consists of:
- Your Python program. Call it, catAndMouseGame.py. Include all necessary files (e.g., images, sounds, etc.)
- A printout of your program - to be submitted in class on the due date.
- Be ready to play (demonstrate) your game in class.
Your grade will be based on how well you followed the above instructions.