Concept
This project is a creative expansion of my initial experience with p5.js, where I first ventured into the world of coding shapes and sketches. In our very first week of classes, we were encouraged to explore and create a house using p5.js. Now, for this assignment, I’ve revisited that initial sketch of a house, but with a twist. I aimed to breathe life into it by adding animation and interactivity, combining the fundamentals we learned previously with new elements. Additionally, winter is my favorite season, and I wanted to capture its essence in this project. To convey the beauty of winter, I decided to add falling snow in the background that accumulates on the ground as it descends. This not only adds movement and interactivity but also creates a serene winter landscape.
Highlight of the Code
One of the standout features of my code is the dynamic snowfall. Each snowflake is generated with a random position and speed, and they fall gracefully to the ground, accumulating over time. Here’s a snippet of the code responsible for this:
// Generate 300 random snowflakes with positions and speeds. for (let i = 0; i < 300; i++) { snowflakes.push(createVector(random(width), random(height), random(minSpeed, maxSpeed))); } // Update and draw each snowflake. for (const snowflake of snowflakes) { snowflake.y += snowflake.z; // Move the snowflake downwards. fill(255); // Set the snowflake color to white. rect(snowflake.x, snowflake.y, 1, 1); // Draw a small rectangle for each snowflake.
Moreover, I’ve added an interactive element where users can increase the snowfall by clicking on the canvas background. Additionally, pressing the mouse button while moving increases the snowfall, allowing users to control the intensity of the snowstorm dynamically.
Reflection/Improvements
While I’m pleased with the outcome, I recognize that there’s always room for improvement and further exploration. One possible avenue for improvement is to introduce a day-and-night cycle. By implementing this feature, the project could dynamically transition between day and night, altering the mood and atmosphere. This could involve changing the background color, adjusting the brightness of objects, and simulating the passage of time. Such a feature would not only add visual interest but also make the project more immersive and interactive. As I continue to explore creative coding, I look forward to experimenting with such dynamic elements in future projects, enriching the user experience and pushing the boundaries of what’s possible.