Week 2 HW) Loops

My project actually started from something very different from how it ended. I was trying many different things- things as simple as printing smiley faces where the mouse is clicked. Looking at the subject, I thought ‘what would happen if I use a loop for this project?’

The first step was increasing the x and y positions by 1. When I did this, everything looked the same (as expected). So I added random values to the x and y positions, which made things a bit more dynamic. At this stage, the random number was set once and the same value was added over time. (For instance, the variable tempX, which is a random value I’m referring to, would be initialized and set once, and never be changed. So, the circles were moving in a uniform way, with only the speed of movement different.) So, I added more lines to continuously  reset the random value that’s being added to x and y position, which gave the result we are seeing.

while(x + tempX < 401 && x + tempX >= 0 && y + tempY < 401 && y + tempY >= 0){
    tempX = random(-5, 5);
    tempY = random(-5, 5);
    x = x + tempX;
    y = y + tempY;
    drawSmile(x, y);
  }

The code I want to emphasize is the part where I reassign random numbers over and over, in order to create the dynamics here.

I think the project can be improved by maybe manipulating the frequency of redrawing, or drawing multiple types of random shapes, rather than just having circles every time. I also think it might be cool if I can limit the drawing to a certain area, and use the rest of the space with other types of media.

Leave a Reply