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.
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.