This week we are required to use different kinds of forces to create a natural phenomenon. After seeing the requirement, I decided to create a scene that shows the storm very soon. Since I feel I still in the phrase of explore oop, vector math and forces. This week my goal is still learn and understand.
I tried to use the code I can fully control. Firstly I chose the sample code of snow as my base code. Then I copied some useful part of the sample code and revised them. I also adopted vector method. https://editor.p5js.org/MOQN/sketches/dcKrwkt16 NOC OOP Applications - snow
Then, I began draw the background, I used the vertex function to adopt a lot of dots and link them to shape the mountain.
Then I started to make the ball dynamic. First I set the initial number of balls to 100 and gradually increase the number.
Because I wanted to mimic snow and storms, I chose three forces: gravity, air resistance, and wind. I first apply a downward vector to the ball as gravity, and then apply that force. In addition, I set the values of friction and Restitution. Simulate the atmospheric resistance of snow and reduce its speed.
And then I started thinking about the wind, and I thought of the wind as a vector to the right that every time the mouse pressed it, it looked like a strong wind blowing through snow.
I also used keypressed function to stop the ball and pressed again to start the ball. Make the project more interactive.
Finally, I cleaned up the code and adjusted the values to make the picture look as beautiful as possible. Through the process, I learned a lot. The project deepen my understanding of physics simulations and how to bring them to life interactively. By simulating forces like gravity and friction, and adding user interaction, I was able to create an engaging and dynamic experience. Moving forward, I would consider adding more features, such as collisions between balls or additional types of forces, to further expand the simulation.
One of the most challenging parts of this project was accurately simulating the effects of gravity and friction. Understanding how to apply forces to the objects and ensuring they interacted in a realistic manner was crucial. I learned a lot about vector math, especially for simulating forces in 2D. The p5.js library made it easier to handle vector math without needing to manually code all the math.