NOC – Week 6: Ping Pong – Collision (Lily)

I have created a Ping Pong game with collision this week 😛

The bat is controlled by the x, y position of the mouse. The number of Ping Pong balls that are not touched by the bat will be displayed in the background. When the number reaches 20, the game is over.

In order to keep the webpage smooth, I wrote a “checkEdges” function that uses splice to remove each ball when it is out of the window. 

Demo:

Leave a Reply