This homework has two parts: programming practice due Sunday, and a required tutorial to be completed before Tuesday night.
-
Assignment: Follow the Processing Objects tutorial.
-
Assignment: Email me answers to the following questions to jzamfirescupereira@cca.edu by Tuesday night: Send 3-4 sentences per question.
-
In what ways is a class like a cookie cutter?
-
What sets apart instance variables from regular variables?
-
In the following code, how many instances of Ball are created in total?
-
class Ball {
float x, y;
Ball(float x, float y) {
this.x = x;
this.y = y;
}
void display() {
ellipse(x, y, 50, 50);
}
}
Ball b = new Ball(100, 100);
Ball b2;
void setup() {
size(500, 500);
b = new Ball(120, 200);
b2 = new Ball(35, 35);
noStroke();
}
void draw() {
background(255);
fill(128, 178, 255);
b.display();
b2.display();
}
-
Assignment: Pick 5 of the 15 sketches below and recreate them, at least one must be animated. Bonus points for adding flourishes to your sketches. Create a new GitHub repository for this assignment, and create a new file for each of your five sketches -- include the sketch number in the file name. Email a link to your repository to jzamfirescupereira@cca.edu by Sunday, September 13.
-
Not all these sketches are equally difficult -- in fact some are very challenging!
-
You may find the following Processing tutorials helpful:
-
It may also help to read through the Processing reference to understand all the various functions available to you.
-
For extra programming help, consider following the Khan Academy programming tutorials using Processing.
Without further ado, here are the sketches:
-
Circles in a diagonal line. Use a while loop to draw the balls in sequence. What do you know about the x and y coordinates of each ball? (Spoiler: They're the same!)
-
Circles in a grid. You will likely need a while loop inside another while loop!
-
Colored circles in a grid, random version. Check out the
colorMode
function, and HSB, in the Processing reference. -
Colored circles in a grid, sequential version. Check out the
colorMode
function, and HSB, in the Processing reference. Note that the colors shift from left to right and from top to bottom! -
Circles in an triangle.
-
Circles in an hourglass.
-
The grid.
-
Diagonal lines.
-
Diagonal lines, interrupted.
-
Random bars.
- Random bars, animated.
- Animated bars, mouse-sensitive. Check out the Processing-defined variables
mouseX
andmouseY
in the Processing reference.
- Bouncing balls, just two.
- Challenge: Bouncing balls, more added by clicking. You may need to use an
ArrayList
.
- Challenge: Fireworks! They should track the mouse and appear on clicks.