NOC – Week 6: Collision and Infection – Susan Xu

Sketch

I continued the code from class with balls attracting to and colliding with each other. I changed checkEdge() to make balls bounce off the wall with restitution (it can also cope with some crazy velocity scenarios). I extends a class Electron that is constructed with pos and vel, depending on mouse position and movement.

Newly created small red balls hitting yellow balls

Besides, I played the collision with the color of the ball in this sketch. The electrons will “infect” the yellow balls as the number of collision accumulates. In the end, all balls in the screen will turn red.

Yellow balls turning orange then to red.

Leave a Reply