Mini Project 7: Particles
For this mini project, the main focus was on particles and manipulating their movements by coding in behaviors and methods. We were to use a class for the particles, and add in at least 3 features to add to its movement, and also to create effects. I wanted to depict a scene of snowfall in the winter. To achieve this, I coded the particles to appear from the top of the screen, and fall to the bottom, where they then reappear, making the motion nonstop. I also wanted the result to be interactive, so I added in the keyPressed feature so that once the key “q” is pressed, then clouds appear, and the particles start to shift right and move faster. I also wanted to create a visual effect where the snow piles at the bottom as each particle falls, but encountered some difficulties with the code. Due to this, I decided to make the appearance give off a facade effect, similar to a gif where each frame restarts. Object oriented programming is when the code is characterized by implementing classes of objects linking them with methods. A class is essentially a template for creating objects, making it more simple to replicate multiple versions of the same object. Object oriented programming is useful when you want to create the same objects, while modifying slight aspects of them; it simplifies the code and saves time. The object I made was snow, using class to define it as Particle. The properties I implemented into the particles include diameter, x speed, and y speed. The methods I used to fulfill my outcome include reappear, slowDown, keyPressed, and pile. Reappear makes it possible for the snow to constantly fall once it disappears from the bottom of the screen. Once the mouse is clicked on the canvas multiple times, slowDown makes it possible for the particles to slow down with every click. I used keyPressed to spawn clouds, while also making the particles shift right and move faster. Pile was used to create the visual effect of snow piling on the ground. This project was quite difficult for me to carry out my initial visual because it was confusing to make the particles have the exact visual effects I wanted. Overall, my project looks quite simple, but it was incredibly difficult to code it properly as I experimented with various trials and errors.