Assignments by week:
Fall Term:
Winter Term:
Spring Term:
Monday, October 1
Description
Introduction to Functions
Homework
Tuesday, October 2
Description
Function Practice
Homework
- Here are the functions that we worked on in class today. Those that we didn't solve together in class are your homework tonight:
- Write a function that determines if the distance between the current mouse position and the previous mouse position is greater than a given amount. The function should take a single float that is the minimum distance, and should return a boolean. The function returns true if the absolue distance between mouse locations is at least as large as the amount provided in the parameter. You may use processing's built-in dist() function to calculate the distance.
- Write a function that takes a single integer as its parameter, representing some number of seconds. The function does not return any values. Instead, it uses println() statements to output the number of hours, minutes, and seconds that are needed to represent the given number of seconds. For example, if the number of seconds was 342, the method would print "0 hours, 5 minutes, 42 seconds". If the number of seconds was 90000, the method would print "25 hours, 0 minutes, 0 seconds".
- Write a function that determines if the given year is a leap year or not. It accepts a single integer parameter: the year value to test. It returns true if the given year is a leap year, and false otherwise.
Thursday, October 4
Description
More Function Practice
Homework
- Create a function called
house()
. It takes no parameters and returns nothing. The function draws a house that is centered at the origin (0, 0). You don't need to turn this in to me, but be ready to use it during your next class.
- Read the processing site tutorial on 2D Transformations. You may also wish to read the reference entries for the functions introduced:
Friday, October 5
Description
Coordinate Transformations
Homework
- Write a house function that draws a house centered at (0,0) [the origin]
Now, use coordinate transforms to move the house wherever you want.
- Write another "house" function that takes two parameters: x and
y. The function should draw a house centered at x and y, using
matrix transformations (translate()) instead of altering the
coordinates.
- Write a house function that takes 4 parameters: x, y, scale, and
rotation. The function should draw a house centered at that
location, then rotated by the given number of degrees, then scaled
by the given factor. You may want to call one of your other house
functions from this function so you don't have to copy and paste all
the code (just add the bits that do the rotation and scale).