Post-Mortem: A Cup of Rain

In the making of “A Cup of Rain,”  I have run into several technical challenges.

The first was creating the collision effect among raindrops. Since these rain drops are called from an ArrayList, I did not know their specific coordinates to write the function. The most similar code in our class labs is the separation function in one of the Flocking exercises  (NOC_6_07_Separation).  This function, however, is put into the class file because all the objects share the same radius, In my game, it is not the case, so getting the coordinates for each rain drops become a challenge. At the end, I used several return functions in the class file to extract the x, y and radius, and this method is working.

After getting the coordinates, the problem became how to compare the distance between object to create the colliding effect. Again, the problem is posed by the ArrayList because originally I thought there can only be one “for” loop and therefore the set of rain drops have nothing to compare with. I eventually found out that I can use a loop within a loop, which looks like this:

for (Raindrop r1 : raindrops) {
for (Raindrop r2 : raindrops) {

This double loop solved my problem perfectly, and when those two problems were solved, others parts of the making process were much easier to deal with.

As I mentioned in the previous post,  I imagined the game to have other playing mechanics  such as connecting and matching. For future improvement, I want to add this feature in, and perhaps also increase the diversity of the objects.