CMSC110 (Introduction to Computing)

Assignment #2

Due by 10:10 am on September 19, 2011

Task: Design an interactive sketch that does the following:

Somewhere within your sketch, you must use (1) variables, (2) conditional if or if-else statements, and (3) for or while loop iteration.

Other hints:

    1. Begin by randomly generating the background.  Develop this slowly, building up complexity as you go.  Test it to make sure it works after every few lines of code.
    2. Add in the keyPressed() method that clears the background.  Test that it works.
    3. Add in the mousePressed() method to draw a simple shape (e.g., a single ellipse) at the mouse location upon a click.  Test that you can draw multiple objects and randomly regenerate the background.
    4. Change the simple shape to the more complex looking object you want to draw.  Test your code.
    5. Modify your complex object to adjust some aspect of its appearance (i.e. shape or size) based on the mouse location.  Test your completed program.



Use the following structure for your program.


// Header comments
// Declare variables

void setup() {
// Set up the drawing.
// Call the drawBackground() method
}


void draw() { /* remains empty */ }


void mousePressed() {
// Use the mouseX, mouseY position to change the physical shape of your object
// Draw the object
}


void keyPressed() {
// Call the drawBackground() method
}


// clear the entire image and redraw the background
void drawBackground() {
// Draw a background that contains random elements and repetition using a for loop
}


Requirements:

Carefully read the Assignment Submission Policy for how to submit your assignment.