Workshop › Pong › Step 5 of 26
Each paddle is a 10×80 rectangle. We keep each paddle's position in an object (left, right), 20 pixels in from its
side, and draw both from those objects.
```js
const PADDLE_W = 10
const PADDLE_H = 80
let left = { x: 20, y: 160 }
let right = { x: canvas.width - 20 - PADDLE_W, y: 160 }
ctx.fillRect(left.x, left.y, PADDLE_W, PADDLE_H)
ctx.fillRect(right.x, right.y, PADDLE_W, PADDLE_H)
```PADDLE_W and PADDLE_H are the paddle's width and height.{ x: 20, y: 160 } is an object: two named values in one package. left.x reads the x inside left.x is 600 - 20 - 10 = 570, so it is 20 pixels from the right edge.y: 160 centers an 80 pixel paddle on a 400 pixel court.const ctx = ..., leave an empty line and write the two sizes, then after an empty line the two paddles.fillRect lines. Press Run.Skills: Drawing on a canvas, Game states
← The whole net A function that draws →