CMSC 110 (Introduction to Computing)

Assignment#3

Due before start of class on October 3, 2012

First, read Chapters 1, 2, 3, 4, 5, 6 & 7 from Shifman's text.

Design two objects -- whatever you feel like drawing. For each object, write a function to draw that object of the following form:

void drawMyObject(float x, float y, float objectWidth, float objectHeight) {
...
}

Insert the name of your object in place of "MyObject" in the function name. Since you are drawing two objects, this will result in two functions, drawMyObject1() and drawMyObject2().

Write a program that draws several versions (at least 3) of each object in a 500 x 500 sketch. Use the random number function to generate x, y, objectWidth and objectHeight values, so that the sketch changes each time it is run. You can also vary the coloring of the object, or any other properties, each time it is drawn.

At least one of your objects must interact with the mouse in two manners:

1.  Based on the position of the mouse.  You can design this interactivity however you like, but here are some ideas to get you started:
• Having eyes that follow the mouse position
• Flapping wings as the mouse moves
• Changing color as the mouse gets closer to the object
• Anything else you like!
1. Based on when the mouse is over the object.  Again, you can design this however you like, but here are some ideas:
• Smiling if the mouse clicks on or travels over the object.
• Getting angry (e.g. changing to red, snarling, etc.) if the mouse travels over the object.
• Saying something in a text balloon when the object is clicked on.
• Anything else that interests you!

While you may have an object that follows the mouse (i.e., is drawn at a location based on mouseX and mouseY), you cannot count this toward either of the two interactive components.

Pay special attention to the aesthetic aspects of your design as well as interactivity.  Your sketch should be creative!!

Hints:

• Keep it simple at first.  Start with something basic, get it working, and then build upon it piece by piece, each time ensuring it is working before you move on to the next piece.
• Start with a hand-drawing of what you want, preferably on graph paper.

Requirements:

• Two functions, each of which draws a separate object.
• The position and size of the object must be variables given by the functions.
• The values of the position and size of the objects should be randomized each time the sketch is drawn.
• At least one of the objects must interact with the position of the mouse.
• At least one of the objects must interact when the mouse is over the object.