Workshop › Pong › Step 17 of 26
Each paddle gets a score. When the ball gets past a player, the other one wins the point, then the serve goes to the player who lost it.
```js
let left = { x: 20, y: 160, score: 0 }
let right = { x: canvas.width - 20 - PADDLE_W, y: 160, score: 0 }
function point(winner) {
winner.score += 1
// Serve toward the player who just lost the point.
serve(winner === left ? 1 : -1)
}
if (ball.x + BALL < 0) point(right)
else if (ball.x > canvas.width) point(left)
```score field starting at 0.point(winner) adds a point to the paddle that won it.1), otherwise left (-1).score: 0 to both paddles.serve, write point.update, change the two serve(...) calls to point(right) and point(left).Skills: Game states
← Serve again Show the score →