Download - Scratch Pong Remix Tutorial

Transcript
Page 1: Scratch Pong Remix Tutorial

Scratch allows you to create and share your own interactive stories, games, music, and art.

Tutorial by John McDonaldhttp://scratch.mit.edu/users/jwmcdonald24

http://scratch.mit.edu/

Page 2: Scratch Pong Remix Tutorial

Download and Install

Page 3: Scratch Pong Remix Tutorial

1. Go to the Scratch website http://scratch.mit.edu/2. Click the “Download Scratch” button.3. Choose the appropriate version and download/run

the installation.

Page 4: Scratch Pong Remix Tutorial

Fill out the form and click the “Sign up” button at the bottom of the page.

Page 5: Scratch Pong Remix Tutorial

Prepare Your Project

Page 6: Scratch Pong Remix Tutorial

1. Open Scratch to a new program.2. Right-click the cat sprite and select delete.

Page 7: Scratch Pong Remix Tutorial

1. Click File and choose “Save As…”2. Give your project a name.3. Type your name under “Project author:”.4. Type any comments under “About this project:” and

press “OK”.

Page 8: Scratch Pong Remix Tutorial

Create the Sprites

Page 9: Scratch Pong Remix Tutorial

1. Select the Stage icon in the sprites section below the stage preview.

2. Click the “Backgrounds” tab in the center section.3. Click the “Edit” button.

1

2

3

Page 10: Scratch Pong Remix Tutorial

This brings up the Paint Editor:

1. Select the paint bucket icon.

2. Fill the stage with black.

12

Page 11: Scratch Pong Remix Tutorial

1. Select the line icon.2. Choose the white color.3. Draw a centered vertical

line.4. Click “OK”.

12

3

Page 12: Scratch Pong Remix Tutorial

Click the “Paint new sprite” icon above the sprite window.

Page 13: Scratch Pong Remix Tutorial

1. Select the circle button.2. Make sure the fill button is selected.3. Hold the shift key to constrain the sprite to a perfect circle as

you draw.

1

23

Page 14: Scratch Pong Remix Tutorial

1. Select the paint bucket.2. Change the color to

white.3. Fill the circle with

white.4. Press “OK”.

1

2

3

Page 15: Scratch Pong Remix Tutorial

1. Select the “Shrink Sprite” button above the stage preview.

2. Click the ball on the stage repeatedly until you are happy with its size.

3. Right-click to deselect the “Shrink Sprite” button.

1

2

Page 16: Scratch Pong Remix Tutorial

1. Select the rectangle button.2. Confirm the fill button is selected and black is the

color.3. Draw a thin, vertical rectangle.

1

2

3

Page 17: Scratch Pong Remix Tutorial

1. Select the paint bucket.2. Change the color to white.3. Fill the rectangle with white.4. Click “OK”.

1

2

3

Page 18: Scratch Pong Remix Tutorial

1. Right-click the rectangle sprite and select “duplicate”.

2. Click the “Paint new sprite” icon above the sprite window.

Page 19: Scratch Pong Remix Tutorial

1. Select the text (T) button.2. Click within the editor and type “You Win!”3. Click “OK”.

1 2

Page 20: Scratch Pong Remix Tutorial

1. Click the “Paint new sprite” icon above the sprite window.

2. Select the text (T) button.3. Click within the editor and type “You Lose…”4. Click “OK”.

1 2

Page 21: Scratch Pong Remix Tutorial

1. Click on Sprite1 (the ball) in the sprite window.2. Rename “Sprite1” to “ball”.3. Repeat steps 1 & 2 for the rectangle sprites

renaming them “paddle1” and “paddle2” respectively.

1

2

Page 22: Scratch Pong Remix Tutorial

1. Click on Sprite4 (“You Win!”) in the sprite window.2. Rename “Sprite4” to “win”.3. Click the “Paint” button to the right of “New

costume:”.

1

2

3

Page 23: Scratch Pong Remix Tutorial

1. Select the text (T) button.2. Click within the editor, type “You Win!” and highlight the

text.3. Click the white color swatch to make the text white.4. Click “OK”.5. Repeat all the steps from the previous slide and this slide

for “Sprite5” (“You Lose…”).

1

2

3

Page 24: Scratch Pong Remix Tutorial

Drag all of the sprites to their proper locations on the stage preview as shown above.

1

Page 25: Scratch Pong Remix Tutorial

Working with Script Blocks

Page 26: Scratch Pong Remix Tutorial

1. Select the “ball” sprite in the sprite window.2. Click the “Control” button in the top left window.3. Drag the correct script blocks over into the script

window.

1

2

3

Page 27: Scratch Pong Remix Tutorial

1. Snap the “if…else” block into the “forever” block.

2. Snap the “if” block onto the “wait 1 secs” block.

3. Confirm that you have the correct control blocks for the “ball” sprite.

1

2

Page 28: Scratch Pong Remix Tutorial

1. Click the “Motion” button in the top left window.

2. Drag the correct script blocks over into the script window.

3. Snap the correct blocks into their proper place as shown.

1

2

3

Page 29: Scratch Pong Remix Tutorial

1. Click the “Operators” button in the top left window.

2. Drag the correct script blocks over into the script window.1

2

Page 30: Scratch Pong Remix Tutorial

Snap the correct blocks into their proper place as shown.

Page 31: Scratch Pong Remix Tutorial

1. Click the “Sound” button in the top left window.

2. Drag the “play sound” block over into the script window.

1

2

Page 32: Scratch Pong Remix Tutorial

Snap the correct blocks into their proper places as shown.

Page 33: Scratch Pong Remix Tutorial

1. Click the “Sensing” button in the top left window.

2. Drag the correct script blocks over into the script window.

1

2

Page 34: Scratch Pong Remix Tutorial

Snap the correct blocks into their proper place as shown.

Page 35: Scratch Pong Remix Tutorial

1. Click the “Variables” button in the top left window.

2. Click the “Make a variable” button in the window below the script categories.

3. Name the variable “speed” and click “OK”.

12

3

Page 36: Scratch Pong Remix Tutorial

1. Uncheck the “speed” variable block.

2. Drag the correct script blocks over into the script window.

1

2

2

Page 37: Scratch Pong Remix Tutorial

That is pretty much it for the “ball” sprite’s script blocks.

Confirm that you have the correct blocks and that they are snapped in the proper locations.

Next we will adjust the values of the drop-downs and the text boxes.

Page 38: Scratch Pong Remix Tutorial

Click the drop-down menu in the “touching __ ?” sensor-type script block and select “paddle1”.

Repeat this step for the next “touching __ ?” sensor-type script block and select “paddle2”.

Drag the “direction” script block from the “Motion” script list into the multiplication operator-type script block as shown.

Page 39: Scratch Pong Remix Tutorial

Enter the following values into the appropriate boxes:1. 52. -903. -225 (confirm “x position” and “ball” are

selected in the drop-down list)

4. 225 (confirm “x position” and “ball” are selected in the drop-down list)

5. -16. 57. -208. 209. 2010.0.5

12

3 4

56 7 8

9

10

Page 40: Scratch Pong Remix Tutorial

1. With “ball” still selected in the sprites list click on the “Sounds” tab in the middle window.

2. Click the “Import” button to the right of “New sound:”

3. Open the “Effects” folder in the Import Sound window.

4. Select the “Pop” sound effect.5. Click “OK”.

12

34

Page 41: Scratch Pong Remix Tutorial

1. Return to the “ball” sprite’s “Scripts” tab.

2. Click the drop-down menu on the purple sound-type script block and choose “Pop”.

That completes the setup for the “ball” sprite. Now let’s move on to the paddles.

1

2

Page 42: Scratch Pong Remix Tutorial

1. Select the “paddle1” sprite in the sprite window.

2. Drag the shown script blocks into the “Scripts” window and snap them appropriately as you did with the “ball” sprite’s script blocks.

2

Page 43: Scratch Pong Remix Tutorial

1. Select the “paddle2” sprite in the sprite window.

2. Drag the shown script blocks into the “Scripts” window and snap them appropriately as you did with the “ball” and “paddle1” sprites’ script blocks.

2

Enter the following values in the appropriate boxes:3. Change “x position” to “y position” in all 4 drop-down

lists.4. Change “ball” to “paddle2” in the 2 right-most drop-

down lists.5. 36. -57. 38. 5

3 3

3 3

4

4

56

78

Page 44: Scratch Pong Remix Tutorial

1. Select the “win” sprite in the sprite window.

2. Drag the shown script blocks into the “Scripts” window and snap them appropriately as you did with the previous sprites’ script blocks.

3. Enter 225 for the value in both text boxes.

4. Note that the only difference between these 2 block groups is the top blocks.

2

3

3

Page 45: Scratch Pong Remix Tutorial

1. Select the “lose” sprite in the sprite window.

2. Drag the shown script blocks into the “Scripts” window and snap them appropriately as you did with the previous sprites’ script blocks.

3. Enter -225 for the value in both text boxes.

4. Note that the only difference between these 2 block groups is the top blocks.

2

3

3

Page 46: Scratch Pong Remix Tutorial

1. Click the green flag in the top right corner of the stage preview window to test your game. You can also click the “Full Screen” icon above the red stop button to play in full screen mode.

Sit back and enjoy your game. If it isn’t working properly, go back and verify that all of the script blocks and their values match.

1

Page 47: Scratch Pong Remix Tutorial

Sharing your Project

Page 48: Scratch Pong Remix Tutorial

1. To share your project online first click on “Share” in the Scratch main menu bar at the top, then select “Share This Project Online…”

2. In the “Upload to Scratch Server” window, select a tag(s) and feel free to type in others that describe your project.

3. Fill in your login name and password.

4. Click “OK”.

2

1

3

Page 49: Scratch Pong Remix Tutorial

Your project should now be shared on the Scratch website for others to enjoy and remix.

Page 50: Scratch Pong Remix Tutorial

Advantages:• The Scratch website provides numerous tutorials covering

everything you can do, and the forums’ community is very interactive and helpful.

• All shared projects can be downloaded revealing the code used.

• You can “remix” (modify) other members’ projects.

Disadvantages:• You must provide a birthdate, email, and gender when

creating an account.