Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf ·...

8
Creating a Pong Game in Scratch w New Mexico State University Department of Computer Science Box 3000`, MSC CS Cruces, NM 88003 (575)646-4451 / F: (575)646-7024 Step 1: Log into your Scratch accounts - 1. Go to https://scratch.mit.edu. 2. Click on “Sign in” on the top header-menu. 3. Enter your username and password. Step 2: Create a new Project or Open an existing Project - Create a New Project a. Click on “Create” on the top header-menu b. The scratch window should appear. You can rename your file on the top. Open an existing project a. Click on the briefcase icon right next to your username. b. You should be able to see the following screen. Select the project you wish to open.

Transcript of Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf ·...

Page 1: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

Creating a Pong Game in Scratch

w New Mexico State University Department of Computer Science Box 3000`, MSC CS Cruces, NM 88003 (575)646-4451 / F: (575)646-7024

Step 1: Log into your Scratch accounts -

1. Go to https://scratch.mit.edu.

2. Click on “Sign in” on the top header-menu. 3. Enter your username and password.

Step 2: Create a new Project or Open an existing Project -● Create a New Project

a. Click on “Create” on the top header-menu

b. The scratch window should appear. You can rename your file on the top. ● Open an existing project

a. Click on the briefcase icon right next to your username.

b. You should be able to see the following screen. Select the project you wish to open.

Page 2: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

Step 3: Rename your project ● On the top of the screen is a bar where you can enter the name of your game. Change

the name to “Pong”

a.

Step 4: Choose a Backdrop ● Press the “Choose a Backdrop” button on the bottom right of the screen.

a. b. Choose any background out of the ones that come up on the screen.

Step 5: Add a Ball Sprite

Page 3: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

● Start by removing the cat sprite by pressing the trash can icon attached to the cat sprite. ● Hover your mouse over the blue circle button in the bottom right corner with a cat and a

plus sign. Move your mouse up to click on the magnifying glass.

a. ● Click on the ball sprite. You can see it either by scrolling down or by typing the world

“ball” into the search bar on the top of the screen.

Step 6: Make the Ball Bounce ● Make sure that the ball sprite is clicked, and that there is a blue border around the ball

sprite on the bottom right of the screen. ● Once the ball sprite is selected, add the following code to the center of the screen

a. ● Press the green flag button. The ball sprite should be moving around the screen and

bouncing off the edges.

Step 7: Add a Paddle Sprite ● Hover your mouse over the blue circle button in the bottom right corner with a cat and a

plus sign. Move your mouse up to click on the magnifying glass.

Page 4: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

● Click on the paddle sprite. You can see it either by scrolling down or by typing the world “Paddle” into the search bar on the top of the screen.

a. ● Drag the paddle to the bottom of the screen.

Step 8: Move the Paddle ● Make sure that the paddle sprite is clicked, and that there is a blue border around the

high school sprite on the bottom right of the screen. ● Once the paddle sprite is selected, add the following code to the center of the screen:

a. ● Press the green flag button. When you move your mouse the paddle should move with it.

Step 9: Make the Ball Bounce Off the Paddle ● Select the ball sprite again, making sure that there is a blue border around the sprite on

the bottom right of the screen.

Page 5: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

a. ● Add the following code to the center of the screen, next to the blocks of code that are

already there.

a.

Step 10: (Optional) Add a Score ● Create a new variable name called score by clicking “Make a Variable” in the Variables

section.

a. ● Call your new variable “Score” and press Okay

Page 6: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

a.

Step 11: (Optional) Update the Score ● Make sure your ball sprite is selected and iInsert the following block into your existing

code.

a.

Step 12: (Optional) Reset the Score ● Add the following code to any of your sprites:

Page 7: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

a.

Step 13: (Optional) Add a Line Sprite ● We can add a line sprite to end the game whenever the ball falls past the paddle. ● Hover your mouse over the blue circle button in the bottom right corner with a cat and a

plus sign. Move your mouse up to click on the magnifying glass. ● Click on the line sprite. You can see it either by scrolling down or by typing the world

“Line” into the search bar on the top of the screen.

b. ● Drag the line to the bottom of the screen, below the paddle.

Step 14: (Optional) Make a Game Over ● Make sure the line sprite is selected and add the following code.

Page 8: Creating a Pong Game in Scratchcahe.nmsu.edu/4h/techanddesign/documents/pong-worksheet-2.pdf · Creating a Pong Game in Scratch w New Mexico State University Department of Computer

a.

Your game is now ready to play!