Now we’re getting into the meat of the game.

In Pong, your opponent scores a point by getting the ball behind your paddle. There’s a few things we need to sort out here.

  • The ball needs to detect collision with the goals.
  • The ball needs to disappear for a while when a goal is scored.
  • The ball position and velocity needs to be reset on a “serve”.
  • The score of each player needs to be tracked.

First, let’s sort out collision detection with the goal and resetting the ball. Then we can set up a scoring mechanism.