Nature of Code: Week 6 assignment–Moon(Candy)

Documented by: Candy Bi

Project name: Table Tennis

Professor: Moon

Date: 3/26/2019

Link: https://editor.p5js.org/candy/present/Fa4vDtNzZ

Video: w6

Since we have learned about collision. I really want to imitate such effect as I encounter in real life. I think of table tennis.

I place the 15 balls each by each to form the triangle. Collision fuction is add to each ball by checking the distance between one with other.

To fake the balls going down into the hole. I check the position of each ball and make its size 0 if it is in the black area.

Then I try to  make the balls bouncing on the edges. Two vectors(vx,vy) are created to imitate the bouncing on a solid edge in real life:  vector1.x and vector.y do not change at same time.

Then I add the cue so that the game would be more complete.

By pressing, user add a force to the white ball and thus white ball get a velocity just like in real life when we play table tennis.

Leave a Reply