A Random Galaxy

This week, my challenge was to create a rule-based interactive animation. Instead of working on my own, I teamed up with my classmate James, an experienced programmer, so we’re able to push the limits and went beyond what we learned. We spent a bit of time brainstorming, and came up with a simple idea quickly. We planned to generate ellipses with random colors, sizes and positions, and link them with lines. We put two buttons, one was to add more ellipses, and another was to reduce. The result looked like a colorful constellation, so we called it a Random Galaxy. Click here to see it in action!

For the add and minus buttons, we use if statement to detect the position of mouse cursor and whether it’s pressed, and specify colors accordingly. For the random ellipses, we create a ball object and use array to assign numbers to them. The balls are generated in for loop, and when a new ball is generated, the first ball will be deleted.