In class on Wednesday 2/10, we worked on a class called Car. Each object of type Car represents a primitive graphical automobile, with a few simple attributes (color, speed, size, and location) and manipulable via a small number of methods (draw, undraw, move, and step). I finished work on Car after class. You can experiment with the results by grabbing car.py and cartester.py, placing them in a folder with graphics.py, and running "python cartester.py".
For this assignment, your job will be to write a program showing an animation of a simple underwater scene. Your final program, when runnning, should display a randomly generated collection of fish and bubbles against a suitably watery background (just blue, for example, is suitably watery). As the animation proceeds, the fish should swim back and forth (switching directions when they hit the sides of the window) and the bubbles should rise. When a bubble hits the top of the screen, it should disappear and be replaced by a new randomly generated bubble at the bottom of the screen.
Put your Fish class in a file called fish.py. Put your Bubble class in a separate file called bubble.py. Your main program should be in a file called ocean.py, which will import both the fish module and the bubble module.
If you find this program straight-forward, feel free to add extra features--waving plants, vicious sharks, submarines, or whatever strikes your fancy. These extra goodies, however, should be pursued only for your own pleasure; a straight implementation of the ocean as described in the previous paragraphs will be eligible for full credit.
For the basic motion of the Fish and Bubble objects, you should feel free to borrow liberally from Car. Generating random objects, which you'll need to do, is demonstrated in cartester.py, so again, borrow and adapt as needed.
Two features of this ocean will require some new thinking: making the fish swim back and forth, and replacing the bubbles at the top with bubbles below. To get you started on these, imagine enhancing the animation loop from cartester.py like so:
This modification to the main program would require you to modify Car to have a reverseDirection method, which ought to be quite simple to implement. If you also wanted to make each Car object reverse direction when it hit the left side of the window, how would you modify the main program? Would you need further modifications of the Car class?
As always, I strongly recommend that you create an iterative development plan for yourself. What happens in Phase 1, Phase 2, Phase 3, etc. of your work, and how will you test each phase? Even if you get only a couple phases done (e.g. your Fish swim in only one direction and your Bubbles don't regenerate), you'll have a functional and partially complete project to hand in.
Have fun.