Pong, Properly
π― A ball bounces, a paddle follows the mouse, the score rises and the game ends when you miss.
π‘ The idea behind it
Bouncing is just reversing a direction β and a game needs a clear beginning, middle and end.
π§± Blocks you will need
foreverif on edge, bouncepoint in directiontouching?set score to 0stop all
π¨ Build it
- Paddle: forever β set x to (mouse x). One block, and it feels perfect.
- Ball: point in direction (pick random β45 to 45) β forever β move 10 steps β if on edge, bounce.
- Add: if touching paddle β point in direction (direction Γ β1) β move 10 steps. That last move stops it sticking.
- Draw a red line along the bottom. If touching red β say 'Game over' β stop all.
- Add a score that rises on each paddle hit, and speed that rises with it.
π Make it harder
- Add bricks to break, using clones.
- Add a second player on the keyboard for the top paddle.
π Bugs you will hit
- The ball sticks to the paddle and vibrates: it is still touching when the direction flips. Add a 'move 10 steps' immediately after the bounce.
- The ball goes straight up and down and the game is boring: your starting direction has no sideways component β use a random direction that is not near 0 or 180.
β¬ Need Scratch itself?
Free from MIT, in a browser or as an offline app that needs no connection at all.