Comp 151 Project 7
Due: Sat Dec 2nd at 11:59pm
Summary: You
will have the chance in your penultimate project of your semester with
a fun project. Most of our projects have been smaller projects. Now we
will build on the last project to begin a larger project, more akin to
what we might do in a comp152 class.
Description
Take your solution to project 6 and lets add
a few things to it.
- Move your assets into a folder (all the images and sound files)
- Use your original main function and create_bad_guy and
create_good_guy functions.
- but add a second column of bad guys
- You may either keep your move function or rename it event_loop. The
event_loop (or move) function should take three parameters: The
window, the list of bad guys, and the good guy.
- The event loop should do the following
- move the bad guys up and down in the window (make sure they
don't leave the window) which you already did.
- use a keyboard command (maybe arrow keys, or maybe 'w' and 's')
to allow the player to control the hero and move it back and foth.
(again you already did this)
- if the space key is pressed down, fire a shot/ax/whatever from
the hero right toward the enemies
- if the shot hits the enemy then both the shot and the enemy
should disappear.
- keep score. Every time an enemy gets hit and disappears, add 5
points to the score. Display the score.
- about every 3 seconds, (program it to happen every 4 seconds
based on your time.sleep calls) have one randomly chosen enemy
charge over toward the player's area.
- if the enemy collides with the player, then tell the player
they have lost.
- if the enemy doesn't collide with the player, then when the
entire image is off the screen, it should be removed from all
lists and variables of things you draw and abandoned to the
garbage collector.
- Add sounds. I recommend the pyglet library, It works great cross
platform, . You can use pycharm to install pyglet for you.
- you need a sound for
- the hero firing.
- the hero shot hitting an enemy
- the player losing
- the enemy
- Extra credit available. In order to get the extra credit,
you have to complete the project above before extra credit can be
earned (for reference the base project is about 220 pts)
- for 10 pointts extra credit make the two rows of enemies use
different pictures like you see in my image above (this is not
much for this project - but it might make up a big chunk of lost
credit from an earlier project)
- For 30 points of extra credit make the back line of enemies take
two shots to kill. To do this you will either need to write your
own bayguy class (which is beyond what you will learn in class) or
use a dictionary to hold the back row. (make the Image object the
key - and the number of 'lives' the value. We will be talking
about dicts in class.
- For 20 points of extra credit, give the hero 3 lives. Display
this number somewhere that the player can see it. Each time the
enemy hits the player this number goes down by 1. When it reaches
zero the player now loses the game.
It took me about 2 hours
to put my solution to this project together. You have just about 2
weeks (not including the Thanksgiving holiday) to do this project. I
expect this will take most of you somewhere between 9 and 16 hours to
complete. Please start early. You will have to work on this
some time and then put this one away for a while and come back to it.
You will not be able to put in an all-nighter and finish this one.
You'll need to do a rectangle overlap check in order to do this project.
We'll covered this in class (if you are an earnest go-getter you might see
this before we do it in class). I got this technique from the following
site
http://www.geeksforgeeks.org/find-two-rectangles-overlap/
## Returns true if two rectangles (l1, r1) and (l2, r2) overlap, assumes l1,l2, r1 &r2 are Zelle Points
def doOverlap(l1, r1, l2, r2):
    # If one rectangle is on left side of other
    if l1.getX() > r2.getX() or l2.getX() > r1.getX():
       return False
    # If one rectangle is above other
    if (l1.getY() < r2.getY() or l2.getY() < r1.getY():
       return False
    return True #we could use else but not really needed
Additional Requirements:
Your functions must contain all of your code
except the one line invoking the main function
To help me identify your work, make the name of your program file
yourFirstInitialLastNameLab7.py
(so mine would be JSantoreLab7.py)
Comment your code. include the usual
put the following at the beginning of the program as a comment:
- Your name
- anything that was left undone
- any extra credit that was done
- Anything that I need to know to run the program correctly. Including
how to control the hero.
Submission:
zip the entire folder up again this time - there
will be images as well as python code.
Submit the zip file of the lab via blackboard as
usual. Don't forget to make sure your file has you name in the file name.