CMSC 110 (Introduction to Computing)
Fall 2016
Assignment #5
Due by 1:10pm on Monday, November 21, 2016 (RE) / 12:55pm on Tuesday, November 22, 2016 (DK)
Task: Using object-oriented design, write an interactive program featuring an animation.
You must include some mechanism for adding more animations to the sketch.
Your sketch must also take some action when the user clicks on an existing animation. (Harder alternative: your sketch can take an
action when two animations collide.) Use a class to represent your animation, and
you will need to use an array to model each animated piece. Here are some ideas to get
your creative juices flowing:
- Every time you click on the background of the sketch, a snowflake appears and falls to the ground. If you click on a snowflake,
though, it turns into a raindrop, falling even faster. (Clicking on a raindrop does nothing.)
- The sketch starts with one ball bouncing, but every time you click a ball, it splits into two of different colors. (Harder
alternative: the ball splits into two when it collides with another instead of when you click on it.)
- The sketch shows the audience of a performance. At first, all audience members are stationary. When you
click on one, they begin clapping. When you click again, they stop.
- The sketch shows a starry night. Whenever you click, a meteor appears and streaks across the night sky. If you
click on a meteor, it bursts into flames and rains down stardust.
- The sketch shows a chicken coop. Clicking on the background introduces a new chicken, who walks in from the side
of the sketch to where you clicked. Clicking on a chicken has it lay an egg, which stays on the ground. Clicking
on an egg makes it hatch.
Requirements, as seen by a user:
- Some animated feature that can appear in any part of the sketch.
- A mechanism for the user (or just time) to introduce an unbounded number of these animated features (that is, the user can create
as many as they want, or time will eventually create as many as a patient user wants).
- All the animations need to be animated concurrently (that is, you cannot have just one part be animated at a time).
- An interactive action that takes place when the user clicks on an animated feature. (If your animated feature is not rectangular,
this can be hard. It is OK if you pretend that your feature is a rectangle or other convenient approximation for the purposes of detecting whether or not it has been
clicked on.)
- Harder alternative, replacing the requirement just above: When two of your animated features collide, an interactive action
takes place. Similar to the above requirement, you can approximate the shape of your feature to simplify the math. (Circles are
easier than rectangles for this one!)
Requirements in your code:
- Your animated feature must be encapsulated into a class.
- The class should be designed so that all the animation logic is in the class; your code outside the class should be
rather simple.
- You must use an array to store your class objects.
- Detection of clicking on a feature or collision between features must use an if inside of a for.
Hint: The expand() and append() functions are your friends for adding onto an array.
Hint: We ask you to hand in an image of your sketch. You can create a screen shot
or use the keyPressed() function (look it up in the reference!) to make a call to save().
What to Hand in:
Hand in the entire sketch folder in your
Dropbox folder. Make sure to include:
- Your sketch code (the .pde file)
- A
gif/jpg/png image of your finished sketch
- A write-up with your name, course and assignment number and a
paragraph about the sketch, its inspiration, and how you designed and
implemented it. Include a brief discussion about your experience working
on this assignment.
Hand in a printout of all three class on the due date.