Scratch Tutorial Game – Brick Breaker / Pong Game

This tutorial was written by Allie Burnquist for Start-Up Studio at the Natural History Museum in Albuquerque, New Mexico. It describes a Brick Breaker / Pong Paddle Type game.

  • Create New Project
      1. File: New
      2. Rename Project
      3. Right-Click Cat Sprite and select Delete
  • Create Paddle
      1. Option 1 – Choose new Sprite from Library
      2. Option 2 – Paint new Sprite and name it Paddle
  • Give your Paddle Sprite Motion
      1. Events: Add when flag clicked
      2. Motion: Add go to X: 0  Y: -150
        1. Test: Move your Paddle Sprite anywhere on the Stage and then press the flag on the upper right hand of the Stage. Does your Paddle move back to the starting position?
      3. Control: Add a forever loop under the Motion command
      4. Control: Add an if/then statement inside of the forever loop
      5. Sensing: Add key space pressed? block into the if/then statement. Select the drop down menu on the key space pressed and select right arrow
      6. Motion: Add change x by 10 inside the if/then statement under the key right arrow pressed then and change 10 to 15
        1. Test: Press the flag again to reset the Paddle and press the right arrow key. Does your paddle move right?
      7. Select if/then statement and drag out of the forever loop. Select the duplicate stamp and stamp the if/then statement to create a duplicate. Drag one under the other until they attach. Drag both back into the forever loop.
      8. Select the drop down menu on key right arrow pressed in the second if/then statement, then select left arrow. Change move 15 steps to -15 steps inside of the second if/then statement.
        1. Test: Press the flag again to reset the Paddle and press the left arrow key. Does your paddle move left? Now try the right arrow key. Does that still work?
        2. Note: At any time you can use the duplicate, delete, shrink or grow an item. You can also copy Script from one Sprite to another by grabbing the Script and dragging it over the Sprite you wish to copy to.
  • File: Save Now

Now we have a Paddle that moves both left and right. Time to work on our Ball.

  • Create Ball
      1. Option 1 – Choose new Sprite from Library
      2. Option 2 – Draw new Sprite and Name it Ball
  • Give your Ball Sprite Motion
      1. Events: When flag clicked
      2. Motion: Go to X: 0  Y: 190
        1. Test: Move your Ball Sprite anywhere on the Stage and then press the flag on the upper right hand of the Stage. Does your Ball move back to the starting position?
      3. Motion: Point in direction 90 under Motion command
      4. Operators: Add pick random 1 to 10 into the point in direction, replacing the 90. Change the 1 to 10 and the 90 to 225
      5. Control: Add a forever loop under the Motion command
      6. Motion: Add move 10 steps into the forever loop and change 10 to 15
        1. Test: Press the flag again to reset the Paddle and activate the Ball. What happened to the ball? Try pushing the flag a few more times. Does the ball come down too fast? Try adding a wait 1 second Control before the forever loop. Play with the time. I like .5 seconds. How do we get the ball to bounce back?
      7. Motion: Add if on edge bounce into the forever loop under move 15 steps.
  • File: Save Now

Now we have a moving Paddle and bouncing Ball, but we need to stop the ball from going through the Paddle.

      1. Control: Add an if/then statement inside of the forever loop under the if on edge, bounce Motion
      2. Sensing: Add touching? block Select the drop down menu and select Paddle.
      3. Motion: Add point in direction 90 under touching Paddle
      4. Operators: Add pick random 1 to 10 into the point in direction, replacing the 90. Change the 1 to 90 and the 30 to -30
        1. Test: Press the flag again to reset the Paddle and activate the Ball. Use your right and left arrows to move the Paddle and stop the ball from hitting the bottom of the Stage
  • File: Save Now
  • Prepare the Backdrop and Add Sound
      1. Stage: Backdrops
      2. Add a rectangle along the bottom of the Stage
      3. Select Ball Sprite: Scripts
  • Controls: Add if/then statement inside the forever loop under the first if/then statement
  • Sensing: Add touching color? into the if/then statement. Click the square of color in the touching color? block then select the rectangle on the bottom of the Stage
  • Sound: Add play sound pop into the if/then statement under touching color? block
  • Controls: Add stop all into the if/then statement under play sound pop Sound
  • Test: Press the flag again to reset the game and try to play. Where did the sound go? Stop all ends up stopping the sound before it starts. Try placing a wait 1 second block between the play sound pop and stop all. Try playing with the time until you find one that works. I like .05. Once you find the right time, try to play the game again. Does everything work now? How could the game be better?
  • File: Save Now

If everything is working right there are a few more things we can add to make our video game more dynamic.

  • Adding a Game Over Screen
    1. Option 1 – Choose new Backdrop from Library
    2. Option 2 – Paint new Backdrop
    3. Add text and decorate the page however you would like and move back to the Script for Ball Sprite by clicking on the Ball Sprite
    4. Looks: Add switch backdrop to block in the second if/then statement in the forever loop between the play sound pop and wait .05 seconds. Select the drop down menu on the switch backdrop to block to backdrop 2
    5. Select backdrop 1 in backdrops and press the flag to see if it works. Want to hide the Ball and Paddle Sprites when the Game Over Screen comes up?
    6. Looks: Add hide block into the second if/then statement in the forever loop between switch backdrop to block and wait .05 seconds block and try again.
    7. Events: Add broadcast block into the second if/then statement in the forever loop between hide block and wait .05 seconds block. Select the drop down menu and choose new message and name the message Game Over.
    1. Select the Paddle Sprite
    2. Events: Add when I receive to the Script. Select the drop down menu and choose Game Over message
    3. Looks: Add hide block to the when I receive Game Over event

Right now the Ball and Paddle are hidden so we need to add a show command.

      1. Events: Add when space key pressed. Select the drop down menu and select space
      2. Looks: Add show block to when space key pressed
      3. Select go to X: 0  Y: -150 and drag script away from when flag clicked block and move to the when space key pressed block under show block
      4. Looks: Add hide block to when flag clicked
  • File: Save

This is the final Script for the Paddle! We want to match the start commands with the Ball, so select the Ball Sprite to change the Script and repeat the previous steps.

    1. Events: Add when space key pressed. Select the drop down menu and select space
    2. Looks: Add show block to when space key pressed
    3. Select go to X: 0  Y: 190 and drag script away from when flag clicked block and move to the when space key pressed block under show block
    4. Looks: Add hide block to when flag clicked
  • File: Save

This is the final Script for the Ball Sprite. Next we will create a title screen

  • Adding a Title Page
      1. Option 1 – Choose new Backdrop from Library
      2. Option 2 – Paint new Backdrop
      3. Add text and decorate the page however you would like. Press Script at the top of your work area next to Backdrops.
      4. Events: Add when flag clicked
      5. Looks: Add switch backdrop to block. Select the drop down menu and select the background you created for a Title screen. Mine is called Backdrop 3
      6. Controls: Add forever loop under the Looks command
      7. Controls: Add if/then statement into the forever loop
      8. Sensing: Add key pressed? block into the if/then statement
      9. Looks: Add switch backdrop to block to the if/then statement under the key pressed block. Select the drop down menu and select the game play backdrop with your rectangle at the bottom of the screen. Mine is called Backdrop 2.
        1. Test: Click the flag in the upper right hand corner of the Stage area and play your game. Does everything work? What else could we add?
  • File: Save

This is the final Script for the Backdrops. Now we can either add a score counter.

  • Adding a Score Counter
    1. Select Ball Sprite to enter Ball Sprit Script
    2. Events: Add when flag clicked
    3. Data: Select make a variable and name variable Score (make sure for all Sprites is selected) and check mark Score variable
    4. Data: Add hide variable to when flag clicked block. Select drop down menu and select Score
    5. Events: Add when key pressed block. Select drop down menu and select space.
    6. Data: Add show variable to when space key pressed. Select drop down menu and select Score
    7. Data: Add set to under set variable Score. Select drop down menu and select Score set blank number to 0
    8. Control: Add forever loop under set score to 0 block
    9. Control: Add if/then statement inside forever loop
    10. Sensing: Add touching? block to if/then statement. Select drop down menu and select Paddle
    11. Data: Add change by block to if/then statement under touching paddle? block. Select drop down menu and select Score and set blank number to 1