Focus: Polish & logic refinement
By this final stretch, I was focused on making sure my garden sketch wasn’t just functional — it needed to feel polished, intentional, and beginner-friendly. This phase was where I layered in finishing touches, refactored code for clarity, and made sure every piece of logic was readable and well-contained.
Originally, my mousePressed() function was doing too much. It toggled the day/night state on any click, even when I just wanted to plant a flower. That clearly wasn’t working.
So I fixed it by making the sun (or moon) itself act as the toggle. I used the dist() function to measure how close the mouse click was to the center of the sun/moon. If the distance was less than the radius, I knew the user clicked on the circle:
let d = dist(mouseX, mouseY, 80, 80);
if (d < 50) {
isDay = !isDay;
}
This was a small change that made the interaction feel more natural and purposeful. Now, only intentional clicks on the sun or moon toggle the sky — and flower planting works independently when clicking the ground.
To keep the bees visible at night, I wanted to make them feel like fireflies. During the day, they look like yellow bees. At night, they shift to a glowing lime green using RGBA color mode.
I handled this by wrapping the fill() call in a conditional:
if (isDay) {
fill(255, 204, 0); // Yellow bee body
} else {
fill(173, 255, 47, flicker); // Lime green glow with alpha
}
The bees now feel like part of the environment, reacting to the time of day.