For this week’s assignment, I worked on reorganizing my Minion sketch using functions. At first, almost everything was inside the draw() function. The code worked, but it was very long and hard to read. It was also difficult to understand which part of the code controlled each body part.

I started by separating the drawing into different functions, such as drawBody(), drawEye(), drawArm(), drawLeg(), and drawHair(). This made the draw() function much cleaner. Now I can look at the function names and understand what the sketch is doing without reading every line of code.

I also learned how to use parameters inside functions. For example, instead of writing the body position and size directly inside the function, I can write:

drawBody(150, 100, 200, 300, 100, 255, 220, 0);

Then the function uses variables like x, y, w, and h. This means I can change the numbers inside draw() without changing the function itself. I think this made me understand reusable functions much better.

I also used reusable functions for repeated parts, such as the arms, legs, and hair. The same function can be called multiple times with different values.

image.png

The eye was the most interactive part of my sketch. It follows the mouse within a limited area, and when the mouse is pressed, the Minion winks. I kept this interaction while reorganizing the code.

image.png

image.png

My question:

Whether using the same parameter names, such as x and y, in different functions can cause conflicts, or if they stay separate because they are local to each function.