Pong is a classic arcade game where a ball bounces across the screen and a player moves a paddle to keep it in play. Building Pong in Scratch is a great school project because it combines coding, math, motion, and game design in one simple challenge. Students can see how sprites, loops, variables, and conditions work together to make an interactive game.
The project is small enough to finish, but it still teaches ideas used in many real video games.
In Scratch, the paddle and ball are sprites that follow instructions made from code blocks. The paddle usually moves with the mouse or arrow keys, while the ball moves by changing its x and y position or by using direction and steps. Bounce rules make the ball reflect off walls and the paddle, and score variables track points.
A win condition checks when the score reaches a target number and then stops the game or shows a victory message.
Key Facts
- The Scratch stage uses coordinates from x = -240 to x = 240 and y = -180 to y = 180.
- A sprite moves right when its x position increases and left when its x position decreases.
- Ball speed can be controlled with move n steps inside a forever loop.
- A bounce can be coded with if on edge, bounce or by changing direction after touching a paddle.
- Score can be stored in a variable, such as Score = Score + 1 when the ball passes a goal line.
- A win condition can use if Score = 10 then stop all or broadcast Win.
Vocabulary
- Sprite
- A sprite is a character or object in Scratch, such as the ball or paddle, that can be programmed to move and react.
- Stage
- The stage is the Scratch area where sprites appear, move, and interact during the game.
- Variable
- A variable is a named value, such as Score, that can change while the program runs.
- Loop
- A loop is a set of code blocks that repeats, such as a forever loop that keeps the ball moving.
- Condition
- A condition is a true or false test, such as checking whether the ball is touching the paddle.
Common Mistakes to Avoid
- Forgetting to reset the ball at the start, which is wrong because the game may begin from the last position used during testing instead of a fair starting point.
- Putting movement blocks outside a forever loop, which is wrong because the sprite may move only once instead of continuously during the game.
- Adding to the score every frame while the ball touches a scoring area, which is wrong because one missed ball can give many points unless the ball is reset or delayed.
- Making the ball bounce only on the stage edge, which is wrong because the ball also needs a rule for bouncing when it touches the paddle.
Practice Questions
- 1 The Scratch stage is 480 pixels wide from x = -240 to x = 240. If the ball starts at x = 0 and moves 8 pixels per loop to the right, how many loops will it take to reach x = 240?
- 2 A player wins when the score reaches 10. If the score starts at 0 and the player scores 1 point each time the opponent misses, how many more points are needed after the score becomes 6?
- 3 Explain why a Pong game needs both a forever loop and if blocks. Use the paddle, ball, or score in your answer.