ICM Week 3: Many Ripples

Screen Shot 2013-09-24 at 1.16.28 PMI wanted to make circles that expand repeatedly from the center of a mouse click, so I made a ‘Ripple’ class that has the variables x,y, initial size, speed of expansion, and color. It had a function to reset itself at its initial size, to create an endless loop. The problem was that for every new mouse click, the old ripple would either disappear (if background() was in draw) or stop moving. I had a vague idea that an Array could solve this, but wasn’t sure how, and I thought it looked kind of cool just rippling out from the center of the screen anyway.

I passed the code along to Adarsh, my buddy for this week’s assignment. He introduced an ArrayList to contain each ripple, and saw some areas where the code could be improved. He used an ArrayList instead of a plain old Array because in the latter, we’d need to know how many ripples there are, but we can keep adding/removing from a list. With the ArrayList in place, he got MousePressed working.

Where we’re at so far: MANY RIPPLES (view online  // source code).

Screen Shot 2013-09-24 at 1.17.16 PM

if you click, 5 ripples are added to the arraylist. On KeyPressed, the last five ripples are removed. I talked with Adarsh about some ways we could keep going with this, he’s interested in trying P

Leave a Reply

Your email address will not be published.