CS 111

Fall 2016

Introduction to Computer Science

HW08: Ocean simulation

Due: Monday, 10/24 at 23:55

Prelude

In Lab 04, as a class, we collaboratively coded up Pacman, a cool new class using Zelle's graphical library. It commands more primitive graphical elements such as Circle and Polygon, implements a few standard methods such as draw, undraw, and move, a few important methods such as __init__, makeParts, and step, and a method reverse just for fun.

I polished it a bit to do the things we discussed in the last 5 minutes of class and put it as pacman.py. You can download and run it directly, or use pacmantest.py (requires pacman.py to be in the same directory) to run a more extravagant test. This demonstrates how pacman.py can be run directly but also imported as a module.

If you compare pacman2.py (what we had in class) and pacman.py (polished), you'll see that I mostly used what you wrote. The makeParts function underwent the most amount of change, but I actually used code that another group sent me, so this is very much yours as well!

The program

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 (that generate bubbles), vicious sharks (that eat fish), submarines (that explode when clicked), self-solving Rubik's cubes, 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.

Like the previous graphics homework, I may show some especially impressive work in class. If you do not want your work shown, please mention this in the comments at the top of your ocean.py.

Submission

Upload to Moodle three files: named fish.py, bubble.py, and ocean.py, as described above.

Optionally, you may use zip or tar to package all your project files as a single archive file, and upload that instead. This is especially applicable if you add a lot of extra features (each in its own file!), and it becomes cumbersome to upload one file at a time to Moodle.

Suggestions

This is a somewhat long assignment. Start early! Ask questions. Have fun!