Game tutorial · Pong

How to make a Pong game in Scratch (step by step, with an AI helper)

Pong is one of the first video games ever made, and it is still a brilliant Scratch project: a paddle, a ball and one tricky piece of maths – how to bounce off the paddle. This guide builds a one-player version where the paddle follows the mouse, the ball speeds up as you score and the game ends when the ball gets past you. Every step has real Scratch 3 blocks, and we show where Bee, the AI buddy in Enimist's Maker Studio, can help.

Make the paddle and the ball

Draw a paddle sprite – a wide, thin rectangle about 100 pixels wide – and a ball sprite about 20 pixels across. A plain backdrop with a different colour at the very bottom helps players see where the danger zone is.

Tip: Bee's “Draw for me” chip can draw a fun ball (“a smiling tennis ball”) and a backdrop. Keep the paddle simple so the bounce looks right.

A paddle that follows the mouse

The paddle stays at the bottom and only moves left and right. In a forever loop, set its x to the mouse's x. That is the whole script – the simplest controls in any game, and they feel great.

Prefer the keyboard? Use “key left arrow pressed?” and “change x by −8” instead.

Blocks
when green flag clicked
go to x: (0) y: (-150)
forever
  set x to (mouse x)

Make the ball move and bounce off the walls

Put the ball near the top, point it in a random diagonal direction and move it every frame. “if on edge, bounce” handles the top, left and right walls for free.

Store the speed in a variable “speed” instead of typing a number into “move steps” – you will make the game faster later by changing just that variable.

Blocks
when green flag clicked
go to x: (0) y: (120)
point in direction (pick random (135) to (225))
set [speed] to (6)
set [score] to (0)
forever
  move (speed) steps
  if on edge, bounce

The bounce maths: 180 − direction

In Scratch, direction 0 points up, 90 right, 180 down. When a ball hits a flat paddle, it should keep its sideways movement but flip its up-down movement. The direction that does exactly that is 180 minus the current direction – try it: a ball going down-right at 135 leaves at 45, up-right.

After bouncing, move the ball a few steps straight away so it is no longer touching the paddle; otherwise it can bounce twice and get stuck inside it.

Want more control? Make the bounce angle depend on where the ball hits: point in direction (0 − ((x position of Paddle) − (x position)) × 1.5) sends the ball to the left when it hits the left side of the paddle and to the right on the right side. That is how real Pong lets skilled players aim. Use the “x position of Paddle” block from the Sensing category to read the paddle's position from the ball.

Blocks
if <touching (Paddle)?> then
  point in direction ((180) - (direction))
  move (10) steps
  change [score] by (1)
  change [speed] by (0.5)

Game over when the ball gets past

If the ball's y position goes below the paddle, the player missed. Say “Game over!” and stop. Show the score variable on the stage so players see how many bounces they made.

Because each bounce adds 0.5 to the speed, the game starts calm and gets exciting – a simple way to make difficulty grow by itself.

Blocks
if <(y position) < (-165)> then
  say (Game over!) for (2) seconds
  stop [all]

Ideas to make it yours

Add a sound on every bounce (Bee's “Make a sound” chip can make one: “a short boing”). Add bricks at the top to turn Pong into a brick-breaker: clones of a brick sprite that delete themselves when the ball touches them. Or make it two-player with a second paddle at the top controlled by the A and D keys.

Bee making a sound effect, with Stop and Open the Sounds tab buttons (Vietnamese interface shown)
Bee making a sound effect, with Stop and Open the Sounds tab buttons (Vietnamese interface shown)

Stuck? How the AI buddy can help

The ball sticking inside the paddle is the classic Pong bug. Ask Bee in the Maker Studio: “My ball gets stuck in the paddle” – Bee can see your blocks and will explain the “move 10 steps” fix.

Want Bee to build it? Type what you want – “add a second paddle for a friend with the A and D keys” – and Bee reads your project, prepares the change as a draft card (“Bee will: add 1 script(s)”) and waits. Tap Apply to put it in your project, or Discard; after applying, Undo puts everything back. Then tap “Done” to see how much of the game you made yourself.

Bee built a few blocks from a plan, with Keep, Remove and Try it buttons (Vietnamese interface shown)
Bee built a few blocks from a plan, with Keep, Remove and Try it buttons (Vietnamese interface shown)

Scratch is a project of the Scratch Foundation, in collaboration with the Lifelong Kindergarten Group at the MIT Media Lab. Enimist Studio is not affiliated with Scratch or the Scratch Foundation.

Ready to make a first game?

Open the Maker Studio on a computer – Bee will be there from the very first block.

More guides