Date: 03/03/2019
Links: full screen: https://editor.p5js.org/jz1111/present/vEVlvdoEP
sketches: https://editor.p5js.org/jz1111/sketches/vEVlvdoEP
Video:
I simulated balls bouncing in a completely frictionless environment. The balls are generated by clicking the mouse, with an initial speed and a horizontal acceleration. There exists a constant force as gravity that gives the balls a constant vertical acceleration towards the “ground”. I slightly modified Professor Moon’s update() function by having the vertical acceleration remaining the same to simulate the constant gravity.
I created three buttons at the bottom. With every different button pressed, the balls generated will have a different elasticity. The balls will eventually stop bouncing, but their horizontal speed will remain because there are no horizontal forces.
I also created a head() function for the object to get the direction from the center of the balls to the mouse. In the function display(), the balls rotate an certain angle according to the direction. Thus, the little white ellipse near the edge of every ball will always face the mouse.