Summary:
In
This project you will be defining your own classes and handling events
for the first time. You will create an object from an image. Have it
respond to keyboard controls by moving.
Details:
Create
a pygame windowed program. Your program needs to have a class for your
moving object (the rabbit in my project above.). The class should have
at least the __init__ and update methods. You're class can either use
your complex shape from lab5 for its picture or any (appropriate) image
file that you might have. I suggest png format images since they will
not have the "ugly rectangle around the image" issue. Your object needs
to respond to the left right, up and down arrow keys moving in the
appropriate direction when the keys are pressed. Your object should not
move off of the screen, if the user tries to move off of the screen,
simply stop the movement at the edge of the screen.
You also
need a second non moving object (the egg in my version above). When the
first object collides with the second object, your second object should
dissappear.
Your program should end when the user closes the window.
Additional Requirements and Submission:
- Make sure that your program won't run if it is mearly imported, but only if run as a program (use __name__ for this).
- Make sure to comment your program
- Make sure that you have no more than 5 lines of code at the top level (outside of functions or class methods)
- Submit
in the normal way by sending me an email. Make sure your name is part
of the filename and be sure to include it in the comments in the
program file as well.