CMSC 110 (Introduction to Computing)

Fall 2015

Assignment#3

Due before start of class on Monday, Oct  5, 2015
NO CREDIT FOR LATE SUBMISSIONS

Task: Design a sketch with at least 3 animated elements. The elements could be whatever you feel like drawing. Three concepts should be demonstrated by the elements:

  1. Reflection upon collision.
  2. Wraparound upon leaving the screen.
  3. Multiple items positioned relative to a (moving) reference point.
The reference points for your animated elements should be held in ReferencePoint objects:
/***
 * This class holds reference information for an animated
 * object for drawing.
 */
class ReferencePoint {
  float x; // the xPosition
  float y; // the yPosition
  float deltaX; // the amount to move in the x direction
  float deltaY; // the amount to move in the y direction
}

The following code with setup() definition will create 3 reference points and line them up along the center of the window.

 ReferencePoint centerRef;
 ReferencePoint leftRef;
 ReferencePoint rightRef;

void setup() {
  size(500,500);
  centerRef = new ReferencePoint();
  centerRef.x = width/2;
  centerRef.y = height/2;
  centerRef.deltaX = 1.5;
  centerRef.deltaY = 0.3;
 
  rightRef = new ReferencePoint();
  rightRef.x = width/2 + 100;
  rightRef.y = height/2;
  rightRef.deltaX = 1.5;
  rightRef.deltaY = 0.3;
 
  leftRef = new ReferencePoint();
  leftRef.x = width/2 - 100;
  leftRef.y = height/2;
  leftRef.deltaX = 1.5;
  leftRef.deltaY = 0.3;
}
To draw these as rectangles you could use the code:
void draw() {
  rectMode(CENTER);
  rect(centerRef.x,
       centerRef.y,
       10,
       10);
  rect(leftRef.x,
       leftRef.y,
       10,
       10);
  rect(rightRef.x,
       rightRef.y,
       10,
       10);
}

Write a program that draws your animated elements in a 500 x 500 sketch. You should have a background that is appropriate for the scene you are making with the animation. Your sketch may use some interactivity (using the mouse or keyboard) in some way if you desire.

In your overall sketch pay special attention to the aesthetic aspects of your design as well as interactivity. Be sure to use the programming features you have learned in the last week or two.

What to Hand in:

  1. In a folder named "A3", put an electronic copy of
    1. a short description/reflection of your experience and your intent.
    2. the source code
    3. Your source code MUST be runnable with the "pde" extension.
  2. Zip the A3 folder and submit it to Moodle.