Teaching From Scratch: 6 Activities For Getting Started With MIT’s Awesome Programming Language
Produced by:
Engaging Educators website: http://engagingeducators.com blog: http://engagingeducators.com/blog twitter: @engaginged facebook: http://facebook.com/engagingeducators
Teaching From Scratch: 6 Activities For Getting Started With MIT’s Awesome Programming Language Produced by Engaging Educators
Table of Contents:
Activity
Topic
1
Make Your Sprite Dance
2
Dancing with Sounds, Costume Changes, and “Speech”
3
Drawing Geometric Shapes
4
Adding a Background and Gliding to Coordinates
5
Designing a Coordinate Grid Game
6
Designing a Pong Game
Scratch Activity #1: Make Your Sprite Dance: 1. From the “Motion” category, add move 10 steps block. 2. Click on the block to make the cat it move. 3. From the “Sounds” category, drag out the play drum block. Place it below the move block so they are connected. 4. Click on the drum block to listen (make sure your sound is on) and choose a new sound from the drop-down menu if you’d like. 5. Add another move 10 steps block below the drum block. Put a minus sign in front of the 10. 6. Click on any of the blocks to run the stack and make the cat move back and forth while the sound plays. 7. Add another play drum block to the bottom of the stack. Choose a different sound, and click to play the whole thing. 8. From the Control category, drag a Forever block on to the top of the stack. Make sure it wraps around all the other blocks in the stack. 9. Click any block on the stack to make it run. Click the stop sign in the upper right hand corner to stop the dancing. 10. From the Control category, drag a Green Flag block onto the top of the stack so that when the green flag is clicked, the script will begin. 11. From the Looks category, drag out a Change color block. Do not connect it to the stack that’s already there. 12. Click the change block to see what happens. 13. From the Control category, drag out a When space pressed block. Place it on top of the change block. You can change the key from the drop down menu if you want. 14. Press the key on your keyboard and see what happens. 15. Now you can click the green flag to make the sprite dance and press the space bar to change it’s color. Challenge: Create a new Scratch program that makes a sprite dance. Feel free to explore the different categories and blocks.
Scratch Adtivity #2--Dancing with Sounds, Costume Changes, and “Speech” PART ONE: 1. Click the “Choose New Sprite From File” button:
2. From the folders, choose a new sprite. 3. Delete the original sprite. Right click (control+click on a Mac) on it and choose “delete.”
4.
Create a new costume by clicking the “Costumes” tab: 5. Click the copy button. 6. Click the edit button next to the second costume:
7. Make the sprite face the opposite direction by clicking the “Flip Horizontally” button:
8. Click OK. Click on the Scripts tab to start adding blocks to your script.
PART TWO: 9. From the “Looks” category, add a switch to costume block. Set it to “costume 1” from the pull down menu. 10. From the “Motion” category, add a move 10 steps block. Change “10” to “50.” Make sure the blocks are connected to start building your stack. 11. From the “Sound” category, add a Play drum block. Select any sound you want from the drop down menu. 12. From the “Looks” category, add a say “hello” for 2 seconds block. Replace “hello” with “Hey!” Change 2 seconds to 0.5 seconds. 13. From the “Looks” category, add a switch to costume block. Set it to “costume 2” from the pull down menu. 14. From the “Motion” category, add a move 10 steps block. Change “10” to “-50.” Make sure you include the minus sign. 15. From the “Sounds” category, add a Play drum block. Select a different sound from the pull down menu. 16. From the “Looks” category, add a say “hello” for 2 seconds block. Replace “hello” with “Hoh!” Change 2 seconds to 0.5 seconds. 17. From the “Control” category, add a forever bracket around the entire stack. 18. Make the sprite return to the middle of the screen each time by adding to the top of the stack a Glide 1 seconds to button from the “Motion” category. Change the x and y values both to zero. 19. Click on your stack to test your script.Click on the stop sign to stop it. 20. From the “Control” category add a When Green Flag clicked button to the top of your stack. Now click the green flag and your script should work. Challenge: Create a Scratch program that includes a different sprite, different costumes, sounds, motion, and speech bubbles.
Scratch Activity #3: Drawing Geometric Shapes 1. 2. 3. 4.
Position your sprite in the upper left area of the stage. (Simply click on it and drag) From the “Motion” category, add a move 10 steps block. Change “10” to “100” From the “Motion” category, add a Turn 15 degrees block. Change “15” to “90.” From the “Control” category, add a Repeat 10 times bracket around your stack. Change “10” to “4.” 5. Click the stack and the sprite will walk in the shape of a square. But it’s happening too fast! 6. From the “Control” category, add a Wait 1 second block underneath your Turn 90 degrees block. Change “1” to “0.5” 7. Click the stack and the sprite will walk more slowly in the shape of a square. 8. Make the sprite draw the square. From the “Pen” category add a pen down block (above the repeat bracket and a pen up block below the repeat bracket. 9. From the “Control” category, add a When Space bar Clicked button to the top of your stack. Change the “space bar” to “s” from the drop down menu. 10. Test your stack by clicking the green flag. 11. Drag your sprite to a different part of the stage and click the s key. Repeat to make a work of art made of squares! Note: Need to clear the stage? From the “Pen” category, add a clear block to the scripts area (not connected to anything, just by itself.) From the “Control” category, add a When ___ clicked block above the clear block. Set it so when you click the C key, the screen clears. Challenge: Right click on your stack of code and choose duplicate. Change the duplicated code so that the sprite draws a hexagon when you click the H key. Duplicate again so the sprite draws a triangle when you click the T key. Continue to try to program the sprite to draw another shape. See above note if you need to clear the screen.
Scratch Activity #4--Adding a Background and Gliding to Coordinates 1. Click on the stage icon in the sprites area:
2. Click on the backgrounds tab above the scripts area:
3. Select “import” and in the window that opens, select the xy-grid. 4. Now the background of your stage is a grid. Notice that as you move the cursor around the stage, the x and y coordinates are shown in the lower right:
5. From the “Motion” category, add a Go to X: Y: block. Change so that X and Y are both zero. 6. From the “Motion” category, add a Glide 1 second to x: y: block. Change so that x and y are both 100. 7. Click on the script to test it out. 8. From the “Pen” category, add a pen down block underneath the first block in the stack (Go to x: 0 y: 0). 9. From the “Pen” category, add a pen up block at the bottom of the stack. 10. Click on the stack to test. The sprite should draw a line as it glides to the coordinates.
Challenge: Write a program that makes the sprite draw your initials on the grid!
Scratch Activity #5--Designing a Coordinate Grid Game PART ONE: 1. Click the stage icon and then the backgrounds tab. Select “import” and change the background to the xy-grid. 2. Change the size of the sprite by clicking the Shrink Sprite button and then click on the cat sprite 5 times:
3. Add a new sprite:
4. Select Fish 1-a from the Animals folder:
5. Click the Shrink Sprite button and click on the fish 5 times to make the fish smaller. 6. From the “Operators” category, add two separate pick random blocks. In one, change the range to -240 to 240. This is for the x-axis. In the other, change the range to -180 to 180. 7. From the “Motion” category, add a Go to x: y: block. Then drag the pick random block with the -240 to 240 range into the space for X and the other pick random block into the space for Y. This will make the fish swim to a random spot on the grid. 8. From the “Control” category, add a When Green Flag Clicked block above the Go to block. 9. Test this script by clicking the green flag. The fish should move to a new random spot each time. PART TWO: 1. In the sprites area, click on the cat. The scripts area will be blank. Now it’s time to write a script for the cat. 2. From the “Sensing” category, add TWO seperate Ask ___ and wait blocks. Change “what’s your name” in the first to say “Enter x coordinate” and the other to say “Enter y coordinate.” 3. From the “Variables” category, click Make a variable. This will store the answers. A window pops up asking for a variable name. Give it the name: X. 4. Repeat step 3 except give the second variable the name: Y.
5. From the “Variables” category, add a set x to 0 block beneath the Ask “enter x coordinate” and wait block. 6. From the “Variable” category, add a set x to 0 block beneath the Ask “enter y coordinate” and wait block. BUT, in this variable block, change X to Y. 7. We don’t want the value in the last two blocks to be zero. We want it to be whatever the player answers. So, from the “Sensing” menu, drag an answer block to replace the zero in BOTH set x to 0 and set y to 0 blocks. (Just drag it on top of the 0!) 8. At this time make sure these four blocks in the scripts area for the cat sprite are linked together. 9. From the “Motion” category, add a glide __ seconds to x: y: block. Change the seconds to 5. 10. Make the cat glide to the coordinates the player answers. From the “Variables” category, drag X and Y into the glide 5 seconds to x: y: block so that X and Y both replace zero. 11. From the “Control” category, add a When green flag clicked block to the top of this stack. 12. From the “Control” category, add an If...Else bracket to the bottom of the stack. 13. From the “Sensing” category, add a touching block into the space next to the word “if” in the If...Else bracket. Choose “sprite2” from the drop down menu in the touching block. 14. From the “Looks” category, add a Say ___ for ___ seconds block underneath the “IF” section of the If...Else block. Change “Hello” to “You Win!” and change 2 to 5 seconds. 15. From the “Looks” category, add a Say ___ for ___ seconds block underneath the “ELSE” section of the If...Else block. Change “Hello” to “Try again” and change 2 to 5 seconds. 16. Make the cat return to 0,0 at the end. From the “Motion” category, add a Go to X: 0 Y: 0 block. PART THREE: 1. Test your game by clicking the green flag. This should make the fish move and open a dialogue box asking “Enter x coordinate.” 2. Type that in, click the check mark and you should be prompted to “Enter y coordinate.” 3. Type that in, click the check mark and the cat will glide to these coordinates. If the cat is touching the fish, the fish should say “You win!” If not, it should say “Try again.” 4. Clicking the Green Flag will restart the game.
Challenge: Create a game using the xy-grid background.
Scratch Activity #6--A Pong Game PART ONE--The Lava Background & The Sprites 1. 2. 3. 4.
Click the STAGE icon in the sprites area. Click the BACKGROUND tab. Click the EDIT button. Paint the bottom portion of the stage red/orange to make it look like lava:
5. Click OK. Then delete the cat sprite by right clicking (control + click on a Mac) on it and selecting “delete.”
6. Click the “Paint New Sprite” button: 7. Paint a black dot and click OK. 8. Click the “Paint New Sprite” button again. 9. Paint a short black line and click OK. 10. You now have two sprites: a ball and a pong paddle. PART TWO--The Paddle: 1. Make the paddle move left and right with the mouse. From the “Motion” menu, add a set x to 0 block. 2. From the “Sensing” menu, add a mouse block and drop it into the set x to 0 block on top of the 0. 3. From the “Control” menu, add a Forever bracket around the set x to mouse block. 4. From the “Control” menu, add a When Green Flag Clicked block to the top of the stack.
PART THREE--Making the Ball Move: 1. Click on the ball (Sprite 1) in the sprites area. 2. From the “Motion” category, add a Go to X: Y: block. Set X to zero and Y to 150. This will start the ball at the top of the stage. 3. From the “Motion” category, add a Point in direction 90 block.
4. From the “Motion” category, add a Turn clockwise 15 degrees block. 5. From the “Operators” category, replace the 15 with a pick random __ to __ block. Do this by dropping the pick random block directly on top of the 15. Set the range to 1 to 179. The new block should now say Turn clockwise pick random 1 to 179 degrees. This will make the ball start in a random direction when the green flag is clicked. From the “Control” category, add a forever bracket. This will make the ball bounce around forever. 6. In the forever bracket, add a Move 10 steps block from the “Motion” category. 7. Below that block, add a If on edge bounce block from the “Motion” category. 8. Below that block (and still inside the forever bracket), add a IF bracket from the “Control category. 9. From the “Sensing” category, add a touching ___ block into the blank spot on the IF bracket. From the drop-down menu on the touching block, select “Sprite2” (the paddle). 10. Inside the IF bracket, add a Point in Direction ____ from the “Motion” category. 11. Fill in this blank with a ___ - ___ block from the “Operators” category. (It’s the second block from the top). Type 180 in the first ____. In the second blank, add a direction block from the “Motion” category. This makes the ball bounce off the paddle in the opposite direction. 12. Make it a little more challenging. From the “Motion” category, add a turn clockwise 15 degrees block. Replace the 15 with a block from the “Operators” category that says pick random 1 to 10. Do this by dropping the block directly on top of the 15. Change the range to -20 to 20. 13. In the “Variables” category, click Make a variable. Name the variable “Score.” 14. Add a change score by 1 block from the “Variables” category underneath the Point in Direction block. 15. Add a sound that will play when the ball hits the paddle. Click the Sounds tab at the top of the scripts area. Click import. From the Electronic folder, choose “Zoop.” Or any other sound you want. 16. Click the scripts tab to return to your stack of commands. 17. From the “Sound” category, add a Play sound ___ block underneath the Change score block. Set it to play Zoop (or other chosen sound). 18. Add another IF bracket below the first one. (Still inside the original forever bracket). 19. In the blank of this IF bracket add a touching color __ from the “Sensing category.” Click the little square of color in this block once you’ve added it and a little eyedropper cursor will appear. Click this cursor on the red lava in your stage. Now the bracket will read: IF touching color (red) 20. Go back to the sound tab and import a sound to play when the ball hits the lava. (such as Bell Toll from the effects folder). 21. Go back to the scripts tab and add a Play sound ___ until done block into the second IF bracket. 22. Choose Bell Toll (or whatever sound you imported) from the drop down menu of the Play sound block. 23. From the “Control” category, add a Stop All block below the Play sound __ until done block.
24. Click the Green flag and you should be able to play the game! Your script for the ball should look like this:
EngagingEducators.com
Learn. Teach. Engage.