CMSC 110 (Introduction to Computing)

Fall 2015

Assignment#2

Due before start of class on Monday, Sep  28, 2015
NO CREDIT FOR LATE SUBMISSIONS

Task: Design an drawable object. This could be whatever you feel like drawing. To draw your object, you should use the following function:

void drawMyObject(float x, float y, float w, float h) {
...
}

Insert the name of your object in place of "MyObject" in the function name. For example,

     /**
      * Draws a fruit in an invisible rectangle defined by the upper right hand
      * corner at x,y with width w and height h
      * @param x the right most pixel of the fruit
      * @param y the top most pixel of the fruit
      * @param w the width of the fruit
      * @param h the height of the fruit
      */
      void drawFruit(float x, float y, float w, float h) {
 
          ...
      }

Note: Your object doesn't have to use the parameters in the same way as the example object, but x and y should relate to the position of the object, and w and h should relate to the size of the object.

Write a program that interactively draws several versions of the object in a 500 x 500 sketch. You may use the random number function to generate x, y, w and h values. You can also vary the coloring of the object each time it is drawn. Your sketch should use some interactivity (using the mouse or keyboard) in some way (you can design whatever interactivity 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.

Extra credit: (up to 10 points)

  1. Write a function void drawMyObject(int x, int y) { ... } that
  2. Write a function drawFourMyObjects(int x, int y, int w, int h) {... } that

What to Hand in:

  1. Create a folder named "A2". Put an electronic copy of the description, the source code, the picture of your sketch into the folder A2, and your formatted write-up discussed below. You MUST have your name shown as your signature on your sketch. Your source code MUST be runnable with the "pde" extension. Zip the A2 folder and submit it to Moodle.
  2. Your formatted write-up should have Page#1 showing your sketch, followed by a title, your name, a short 1-2 line description (as discussed in class). Then you should have a short 1-2 paragraph more detailed description of the sketch and your personal experiences working on this sketch, and the source code for your sketch. You may save this write-up as a .pdf, .docx, or .doc file