(Redirected from Pong)

Pong is a game where a paddle is used to hit a ball and bounce it off a wall, allowing it to return towards the paddle. The paddle is on a single axis of movement, parallel to the wall, and must intercept the ball on its return path to keep the game from ending. The ball continues to bounce until this happens. It was originally released as an arcade game in the 1970s, though users have recreated the game on the Scratch Website.

How to Create a Pong Game

Backdrop

First, choose a backdrop. Ensure that the backdrop does not have any of the same colors as the sprite in it, as this will interfere with the sprite created later. Then, draw a line with a distinguishable color at the bottom of the backdrop to represent the area the ball should not touch. The shade of that color created with this line with should not be the same shade as any color in the backdrop or in sprites used.

Creating the Paddle

To create a paddle, create a sprite that is a horizontal line. Then, add the following script to make it follow the mouse-pointer only by the x axis.

when green flag clicked
set y to (-150) //adjust this to change the vertical position of the paddle
forever
set x to (mouse x) //go to the horizontal position of the cursor
end

Vertical Paddle

If one wants a vertical paddle, they can use the following script:

when green flag clicked
set x to (-180) //adjust this to change the horizontal position of the paddle
forever
set y to (mouse y) //go to the vertical position of the cursor
end

Creating the Ball

Create a sprite with a costume of a small circle to represent the ball. Then, add the following script to make it move, bounce, and end the game if it misses the paddle.

when green flag clicked
set [score v] to (0)
go to x:(0) y:(0)
point in direction (pick random (-180) to (180))
forever
move (10) steps
if on edge, bounce //bounce off the edge
if <touching (paddle v)> then //bounce off the paddle
change [score v] by (1) // if the game uses a score, change it with this script
play sound (water drop v) //play a sound effect when bouncing off the paddle
point in direction ((180) - (direction)) //the actual command for bouncing off the paddle
move (10) steps //move away from the paddle when bouncing off it
end
if <<touching color (. . .::grey)> or <(x position) < (-179)>> then //make this the same color of the line at the bottom of the backdrop
stop [all v] //stop the game if the ball hits the bottom of the screen, as it missed the paddle
end
end

External Links

Cookies help us deliver our services. By using our services, you agree to our use of cookies.