Rings of Colorful Balls Simulation – Flow Fields

Here is a link to the simulation of colorful balls following a ring path in a flow field.  Press Spacebar to turn the visibility of the flow field on and off.  Refresh the page to replay the simulation.

Essentially 6 groups of balls with colors of the rainbow are randomly spawned onto the screen with number of balls on the screen ranging from 13 to 70 and the ball’s diameter ranging from 20 to 30 pixels.  The first ball created in its color group is assigned as the leader while the rest of the balls in that group are the followers.  The followers find their leaders and once all of the followers of a particular color group find their leader, then they exhibit an orbiting behavior around their leader.  Meanwhile the white ball seeks the center of the screen and stays there once it gets there.  Once all of the followers have found their leaders, the first ring in the flow field is generated around the center of the screen and the first group in which the followers found their leader begins to steer themselves toward the center of the screen until they enter the first ring.  After all of the followers of the first group enter the first ring, a second ring is generated counterclockwise and then another ring is generated clockwise after the second group of balls enter the second ring.  This goes on until the last group of balls enter the last ring.

This was an interesting project to work on and no one else attempted to use flow fields in their project except for me.  It is now used as an example of a project using flow fields and a custom orbiting behavior for Programming for Digital Media class.

Here is a link to the source code on GitHub:https://github.com/rbVessal/OrbitingColorfulBallsSimulation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s