WEEK 2
LINK TO HOMEWORK SKETCH
For this weeks homework, the section that took me the longest amount of time was Question 3 on the worksheet. I had no problem making circles that moved to different parts of the canvas, but I ran into issues when I tried to turn two of them into object literals, while still being able to change the speed of all of them by only changing one number. I eventually scrapped what I had made and started over, this is the one I threw out.
I started over when I attended the ICM lab with research resident Dave. He helped me see that I was over-complicating it for myself, so I started from scratch. He also helped me understand more about variables that I was still unclear on -- I kept having issues where variables I thought I had defined weren’t being recognized when I ran the program. I learned that my issue was that I didn’t declare the variable before function setup( ); and so it wasn’t recognized as a
Worksheet - Question 3
I simplified my variables from my original sketch and was able to complete it successfully, in a way where by changing only one number, I could change the speed of them all.
For the actual assignment, I created a simple design of a blue sky, window, and table. for the element controlled by the mouse, I set the x and y coordinates of the green ellipse to be mouseX and mouseY, so the ellipse followed the cursor around the screen.
I wanted to make it so that the wall was a new color every time the program was run. The difficult part was doing in a way so that it only changed once, not constantly if it was called in function draw ( );
To do this, I set variables r,g,b,a to be a random number between 0 and 255, in setup, and then called them later in draw to fill in the rectangle of the wall background. This way, it was a different set of random numbers each time.
For change over time, I wanted to make it look like a bird was flying outside. To do this, I set 2 arcs next to each other, to start in the top left corner. In setup, I set the variable counter=1, and used similar methodology of question 3 in the worksheet to set the x and y coordinates of the arcs to be two sets of variables, changing with every iteration to add 1. This way, the bird seemed to move across the screen over time.