Project 9: Angry Birds with Graphics
You may work with a partner for this project. If you choose to do so, only turn in
one copy of the project with both of your names in the comments at the beginning of the code.
If Angry Birds doesn't particularly interest you, you may do one of the challenge
problems at the end of this description, or propose a different
project to me of comparable difficulty. You must get my approval before starting work on it.
For this project, you will write an Angry Birds program with graphics. Your program
must do the following:
- Read in an angry birds file stating the types and locations of the birds.
(sample here) This file contains a description of the starting configuration
of the pigs, only the pigs are named by type. The types of pigs you must
support are are "regular,"
"helmet", "moustache", and "king." (That link is for fun, not because you actually
need to read any of that information.) In your program, each type of pig starts
with a certain number of points. Regular pigs start with 1 point, helmet pigs with
2, moustache with 3, and kings with 5. A pig disappears when its energy drops
to zero or below. When a pig disappears, it leaves a gap where it used to be; the other
pigs do not "slide over" to fill the gap. In other words, the list of pigs always
stays the same length; it does not get smaller and smaller as the pigs are defeated.
- Let the user launch different types of birds at the pigs. You must support
at least the red, blue, black, and white birds, though I encourage you to be creative
and add your own types.
- Display, after each bird launch, a visual depiction of the row of pigs.
The visual depiction should display the pig (a circle is fine) with the energy of the
pig inside the circle (use draw_string from the graphics library).
- When the pigs have all been defeated, end the program.
Main program
Read in your angry birds file and make a list containing the energy levels (points)
for all the pigs. For instance, if your angry birds starting file contains the lines
regular, regular, helmet, moustache, regular, then you'd make a list containing
[1, 1, 2, 3, 1]. (The point of reading from a file is so you can have
different files with different levels of difficulty.)
Then enter a loop that lets the user choose a bird type and launch it. Some bird types
will need to ask the user where they want to launch the bird. Display the pigs
on a canvas after each launch. You may find it helpful to open one canvas at the start
of the program and keep re-drawing the pigs on it; the clear_canvas() function may
prove useful (rather than re-opening and re-closing the canvas after every launch).
This is the minimum you must do for this project. I highly encourage you to add
whatever features you think would be fun. After all, this is your final project,
you're working with a partner, and you two should explore what you've learned and make
this something you can be proud of.
Bird types you must include
- A red bird is the simplest bird. It is launched at a specific pig,
and always decreases that pig's energy by 1 point.
- A blue bird zooms over all the pigs and decreases all their energies by 1 point.
- A purple bird seeks out the pig with the highest energy still remaining and
eliminates that pig (sets its energy to zero).
- An orange bird seeks out the pig with the lowest energy (but still greater than zero)
remaining and eliminates it.
Hints
- I'm going to leave program design completely up to you. Use whatever functions
you deem appropriate or necessary (there's no "right way" to do this). However,
that doesn't mean you can forget or ignore all of the good coding practices you have learned.
- The graphics do not have to be animated. You just have to show what the row
of pigs looks like after each bird has been launched and the pigs' energies
have been updated.
Possible enhancements
- Add more bird types. Ideas:
- A bird that is targeted at a specific pig,
but also damages the pigs to the immediate left and right as well.
- A bird
that is launched at a specific pig, but then bounces to a neighboring pig and eliminates
it (similar to this bird).
- A magnetic bird that is launched at a target and draws all the other pigs around it
to that target (moves them as close as possible, removing any gaps). This way
you can then launch a bird that damages surrounding pigs next.
- Add more pig types. Change their visual depictions to distinguish between
them. Make it so as they lose energy, they change color or are drawn differently.
- Add barriers that can be destroyed, like in the real angry birds game. For instance,
every pig might be guarded by a certain type of material (e.g., wood, plastic, metal)
that has to be destroyed as well. Different types of birds react differently to different
materials. You can do this by using a second list that is the same length as the pigs
list, that stores the material that guards that pig.
- Store the pigs in a grid (2-d list) rather than a list, and let the pigs be stacked
on top of each other. You can choose how the birds will target the pigs (maybe they
can only destroy the top-most pig in each column first, or maybe they can
target any pig in any row/column, and surrounding pigs will drop down by gravity).
- Use the mouse to let the user pick bird types or launch locations.
- Something else!
What to turn in
Through Moodle, turn in your code as a file called angrybirds_yourLastName_yourFirstName.py.
Alternate challenge programs
Here are some alternate games with graphics you could create.
These are all significantly more difficult as they involve a 2-d grid.
You should feel very comfortable with your programming skills in order to attempt these.
- Angry Birds with a 2-d list instead of a 1-d list.
- Candy Crush Saga
- Minesweeper
- Diamond Dash
- Bubble Safari