How to Make a Pong Game on Scratch
by Skattarine in Design > Game Design
42 Views, 0 Favorites, 0 Comments
How to Make a Pong Game on Scratch
Scratch is a website where people create games and other programs using "blocks" that you drag and drop to a workspace. This is a tutorial on how to make a pong game.
Supplies
All that is needed is a computer, phone or tablet with a web browser that supports Scratch. Scratch only supports Google Chrome, Microsoft Edge, Mozilla Firefox, and Safari.
Create a Project
Press the "Create" button, located at the top of the page. If you do not have an account or you are not logged in, log in or create an account. (If you do not, nothing will save and the next time you want to see it, all progress will be completely lost!)
Add Sprites and Backdrop
Once you've created your project, add a sprite for your paddle and a sprite for the ball that will bounce around. You can find the sprites I used in the library of sprites, which you can find by pressing the button with the cat at the bottom right. I also added a background, but this is optional.
Make the Ball Bounce
Go into the ball sprite and add the "If flag clicked" block. Underneath it, put a "point in direction ( )" block and put a "45" in it. Then, add a "forever" loop. Inside the forever loop, add a "Move ( ) steps" block and add a number of your choice. The smaller or bigger the number, the faster the ball goes. Then, add an "if on edge, bounce" block.
Make the Ball Bounce Off of the Paddle
Great! Now your ball is moving around. But we want the paddle to be able to bounce the ball around, otherwise it would just be a "Bouncing Ball" game instead.
In the Ball sprite, add an "If < > then" block inside the forever loop underneath all of that code you just added. Go into the sensing category and drag the "touching ( ) ?" boolean. Insert it into the boolean slot of the "If < > then" block and make it say "touching ([name of your paddle sprite]) ?". Then, inside the part where you insert block, add a "Turn ( ) degrees" and make the number in it "180".
Control Your Paddle
There are two different ways you can control your paddle. Today, I will just show you how to control it with your arrow keys.
Go into the paddle sprite and add a "When flag clicked" block. Underneath, add a "forever" loop. In the forever loop, add two "If < > then" blocks. Then, get two "Key ( ) pressed?" blocks and make one the left arrow key and one the right arrow key. In the one with the left arrow key, add a "Change x by ( )" block and make the number "-10". Then, in the one with the right arrow key, add another one of those "Change x by ( )" blocks and make the number "10".
Make a Points System
Go back to your Ball sprite. Add another "if < > then" block. Add a "touching ( )?" block into it and make it say "touching ([name of your paddle sprite])?".
Make a new variable and name it "Points". In the "If < > then" block you just added, drag a "change [variable name] by ( )" block and make the variable your "Points" variable. Make the number in it "1".
Add a Game Over
Your game is making progress! But we need one more thing before it's finished...
Go into the Scratch costume library and add the "Line" sprite. Drag it to the bottom under the paddle. Go into that sprite and add a "When flag clicked" sprite. Underneath, add a "forever" loop. Then, add a "If < > then" block and find the "touching ( )?" block in the sensing category. Make it say "touching ([name of your ball sprite])?". Then, inside the "If < > then" block, add a "set [variable] to ( )" block and make the number "0". Then, make the variable your "Points" variable. Then, add a "stop [all]" block.
Share!
Your game is done! Now, you can play your game and share it to the public if you want!