Pong-6 allows us to keep track of the score.

Important Code

All we need to do is increment the score variables for each player whenever the ball goes past their goal boundary.

Think through the two cases separately:

  • if the ball fully leaves the left side, player 2 scored,
  • if the ball leaves the right side, player 1 scored,
  • after either score, reset the ball to the center and return the game to start.

🧩 Challenge: Score goals

Detect when the ball leaves the left or right side, increment the correct score, reset the ball, and return to start.

Desired result placeholder

Powered by WebContainers
Files
Preparing Environment
  • Installing dependencies
  • Starting Vite dev server