Falling Boxes

For the past couple of weeks I have been copying out my code for both ICM and IPC by hand in my notebook and then breaking down what the code is doing in english sentences. This has been an extremely helpful exercise as it allows me to note what I understand and what is still confusing. I also think copying it out by hand helps build my muscle memory for the language.

IMG_8213.jpg

This week we learned about classes and arrays. Im still trying to wrap my head around the logic of arrays works, but I understand more intuitively the benefit of using classes.

I had so many ideas for what I wanted to make. First I tried to make a sketch that was broken up into invisible quadrants. A group of rectangles would start in one quadrant, if you put your mouse in that quadrant then the rectangles would move to any of the other 3 quadrants. This would happen over and over so that you could never touch the rectangles with your mouse. I was not able to figure this out for a couple of reasons. One reason was that the rectangles would move across the screen from when the sketch first started rather than waiting until the mouse was over that quadrant. I also wanted the rectangles to animate as they moved from one quadrant to the next and for the new quadrant assignemnt to be random.

IMG_8210.JPG

I ended up making a sketch where 1000 rectangles rain from the top edge and change colors as they hit each 7th of the canvas. In order to make the rectangles look like they are raining I set the random Y location to be anywhere between -1500 and 0 so that the rectangles would look spaced out. The raining speed is random between .5 and 2 so that the rectangles don’t all fall at the same speed.

See sketch and code at the following link: https://editor.p5js.org/etc319/sketches/Gf7BDbdBz

Previous
Previous

Multi-Square

Next
Next

For Loops