Recitation 7: Particles
I used this recitation as a practice for my Project A, so I tried to use practices to make the effects that mimic the city at night. the problem is that sometimes it maybe too bright
The way of Interaction is like this: users can draw lines freely on the canvas, after that press any key to close the light(make the canvas black) then, they can press on the key “l” to gradually light up the lines they drew.
the code is here:https://editor.p5js.org/zzrrqqq/sketches/4z8sTaEMz
I didn’t record a video because I think it’s more fun to interact.
The difficulty I encountered is basically how to light up the road gradually according to what the user had drawn. With the instruction from Professor Moon, I used “class” to achieve this. Store the spots as classes with four variables on the line into an array, and display elements in the array one by one will help, finally I succeeded, I also apply other changes and particles to it.
Reflection:
1. OOP is programming the movement and display separately, one can do any one of them at anytime without processing other codes. A Class is an object that can be shown and moved on the canvas, it can be freely displayed any number anywhere and user can decide whether to let it move. An example is a ball on the canvas that can either choose to move or not to move.
2. OOP is effective because the movement and display are coded separately, one can easily make changes without influencing other codes and freely decide whether to move. When we need to display same things at different status on the canvas, OOP is extremely useful as people can display them and decide whether to let them move or how to move.
3. I created an object that can be shown only as a line according to mouse and “pmouse” at first but can change color and show other particles when certain key is pressed. I used mouseX, mouseY, pmouseX, pmouseY together with other local values to make that.
4. How to reverse the class, for example, if the “move” asks the ball to go left for 100, how to let it go back to the initial point without creating new periods.