Spinning Box Full of Bouncy Balls

In this sketch, we were assigned to create a physics engine. I chose to keep it fairly simple and create a series of bouncy balls within a box that is spinning in relation to the direction of gravity. The key concept here was understanding the relationship between position, velocity, and acceleration. In this case, acceleration was mainly responding to the changing direction of gravity. The idea came somewhat from the scene above in Inception.

I used the createVector() function to store x and y data for the position, velocity and acceleration and used to vector.add function to add the velocity(change in position) to the position and the acceleration(change in velocity) to the velocity. In this case, the acceleration is constantly changing by rotating over time. See the result here:

Source code here:

Leave a Reply

Your email address will not be published. Required fields are marked *