Scratch Belt Table of Contents //Cover page Table of Contents Getting Setup Getting Started //Initialize Project 1: Start at Start Project 2: Just Keep Moving Project 3: Dance, Dance, Music Project 4: Cat and Mouse Project 5: March Madness Project 6: DEBUG! Lost in Space 1 Help Me! Project 7: Recap 1 //Main Loop Project 8: Prize Wheel Project 9: Amazing Maze Project 10: Pogo Ninja Table of Contents Project 11: Sensei Says Project 12: Street Race Project 13: DEBUG! Lost in Space 2 Help Me Too! Project 14: Recap 2 //Exit State Project 15: Tower of Power Project 16: Fall Down Project 17: Dash and Jump Project 18: Hidden Key Project 19: Home Run Derby Project 20: DEBUG! Lost in Space 3 Help Me Three! Project 21: Recap 3 //End of book Glossary Getting Setup Visit Scratch at scratch.mit.edu Join Scratch (Video Guide) Copy your account below! Username: ___________________ Password: ___________________ Email:________________________ Getting Started Watch this guide for getting up to speed! Youtube Don’t worry! All this will be covered as we move through the book. Project 1: Start at start. Concepts: Events Video Links! We all must start somewhere and the same is true for Scratch. Scratch has special blocks called hat blocks (pictured below) that tell Scratch when to start a script. The text inside the hat block tells us when it will run. This is the event that causes the code to start. When do you think the three hat blocks below will run? 1. Please click this link to open Project 1. 2. Click remix. 3. Select the Rocks. Uh oh! Looks like three of our scripts are missing hat blocks. This means they will never run. Let’s go ahead and fix that. Turn the page. 4. The yellow squares are comments. Comments are useful to explain what your code does. The computer ignores comments as they are only for us humans. Take a moment to read the comments. 5. Test of skills or trial and error? Can you add the correct hat block from the answer bank below to each script? Good Job Ninja! You completed your first lesson. I would say that is a good start! How long can you stay alive in this first game? The difficulty can be adjusted by changing the number inside the “Glide (2) secs to [Rocketship]”. Project 2: Just Keep Moving. Concepts: Events | Motion Video Links! Everything has a place and there is a place for everything! Scratch says where a place is with an X and Y grid. As we move left or right we change our X position. When we go up or down we change the Y position. 1. Open this link and try it out for yourself! 2. Click the green flag and drag the ball to different spots. See how the X and Y positions change? Hone Your Skills. What happens to the Y position when the ball goes under the yellow horizontal line? What happens to the X position when the ball goes to the left of the blue vertical line? Are you able to get the ball slightly past the right edge of the screen? Did the X position go past 240 as the ball is halfway off the right side of the screen? 3. Click this link to open Project 2. 4. Click remix and then select the Fish. 🐟 5. When you click play the shark chases our fish and we can’t move! We need our fish to move when we press a key. Let’s add these blocks. 6. Feel free to change the movement keys. You can use W, A, S, D or any keys you want. 7. Test of skills or trial and error? The ninja decides. Not knowing the solution is ok. Wanting to try and find a solution is just as important as knowing the solution itself. Below is an answer bank. Two of the blocks are correct. Find and attach the block that will make the fish move up, and the block that will move the fish down to the matching hat block from step 5. Did you find the answers? Which block worked for moving the fish down when we press the down key? Which block worked for moving the fish up when we press the up key? 8. Let’s add some realism. We want our fish pointing down or up as it swims. We can control direction with the point in direction block. The fish will match the arrow in the point in direction wheel. Good Job Ninja! You completed your second lesson. Just keep moving and you will be a black belt in no time! Remember fish are ninjas too. The speed of the fish can be adjusted by changing the 10 and -10 to different values. You can use any speed you like for your game. Project 3: Dance, Dance, Music Concepts: Events | Looks | Sound Video Links! In Scratch characters in our game are called sprites. A sprite can be just a simple picture or a collection of pictures. Each frame in the collection of pictures is called a costume in Scratch. For some sprites we can change frames to make the sprite seem like they are moving. These are the different frames of the sprite Ten80. 1. Please click this link to open Project 3. 2. Click remix. 3. We need to add our dancing sprite! To add a sprite to the game click the add sprite button in the bottom right. 4. Select the dance tab at the top. 5. Please select any of the sprites shown below from the tab. The choice is yours! Amon can’t make it to the party. He left his other costumes at home. Sadly, he won’t work well for this game. 😢 6. Once your sprite is added you can click the costumes tab (top left) to see all of their costume frames. Some of Ten80’s costume frames. Click on some of the different costume frames. Notice how your sprite changes to that frame in the game? We can control animations by switching between frames with code. 7. Let’s click back on the code tab (top left). 8. We need to add four hat blocks from events to tell Scratch where to start. You can do this! Setup four hat blocks for up, down, left, and right. You can do arrow keys or W,A,S,D. What block do you think it is? 9. We will use code to switch our costume frame. This will make our character “dance” each time we hit a key. Select the looks bubble from the left-hand side and add a next costume block to each hat block. New code time! You can make your own custom events in Scratch. These are the broadcast blocks. They broadcast an event and cause hat blocks listening for that event to start their code! Do not add these blocks 10. Let’s use broadcast to make some hat blocks that already exist in this project start their code. Add a broadcast and wait to each of the hat blocks. 11. You can change the custom event being broadcasted by clicking on the triangle next to the event. This will give you a drop-down box to pick an event from, or you can click new message to make a new custom event. Please make sure your hat blocks and broadcasts match. W or up arrow should broadcast up and so on. Test Your Work! Click play on your game. Does the arrow point in a direction? Press the key that matches that direction. You should get a green check for matching it! When you miss a key a red X should appear. Ask a sensei if one of these isn’t working right. 12. What is a dancing game with no music?! Let’s add a sound to our sprite. Click the sound tab on the top left. Just like the costume tab the sounds tab shows all sounds that are part of this sprite. Ten80 already has one sound shown here. 13. We can add a new sound by clicking the speaker in the bottom left. I marked it with a black arrow for you in the picture. 👍 14. Select the loops tab. 15. Hover over the play button on any of the sounds from loops. Found any that you like? Click on it to add it to your project. 16. Click back on the code tab. 17. These next three blocks are the easiest way to add background music to any game. We want when green flag clicked from events, a forever loop from control, and a play sound until done from sounds. The sound you picked may have a different name. Make sure to select the sound you want by clicking the triangle next to the name. Good Job Ninja! You completed your third lesson. I think you are getting the beat of things. We will cover that forever block more in-depth in the next lesson. For now, just keep grooving right along. Project 4: Cat and Mouse. Concepts: Motion | Control | Sensing Video Links! Like a mouse drawn to cheese I see the ninja is drawn to becoming a code master. Let’s get started grasshopper. 1. Click this link to open project Project 4. 2. Click the remix button. 3. Select the Cat sprite from the bottom. 🐈 We want the cat to do some code when the green flag is clicked. The cat needs to do some pre-chase warmups. The cat needs to get ready for a new game. 4. Add this code to the cat. Wait 1 seconds can be found in the control bubble. This code starts when the green flag is clicked, the cat goes to the starting position, and then Scratch stays at the wait 1 second block. Scratch won’t go past that block until 1 second has passed. Just like how we tell Scratch where to start we have told our cat how to start. We initialized the cat with some basic code to do only once at the start of each new game. Next is the main loop. The cat needs to keep chasing until it catches the mouse. 🐭 Pretend you’re helping your friend in Minecraft get to bedrock. You tell them to dig down and they break one block and ask what to do now. You tell them to keep digging down until they hit bedrock. Do not add this. Disclaimer: Never dig straight down in Minecraft. 5. Let’s turn that same idea into code for catching the mouse. The move 12 steps will move in the direction the cat is facing so it does the change x or y for you! 6. The cat should keep chasing until it catches the _________? Select the cat’s target for the touching block. It should point towards the target and move 12 steps towards it. Select the cat’s target for the point towards block. 7. After the mouse is caught the cat needs to do some exiting stuff. Think of it as the cleanup after a party. This code will only one once after the mouse is caught. Looks bubble Control bubble Just like how we can tell Scratch to start the game by clicking the green flag we can tell it to stop the game by clicking the red stop sign or using the stop all block. 8. Select the mouse sprite. 9. Test of skills or trial and error? We want the mouse to initialize (start) in the top left corner. Which of these will have our mouse start next to the green flag at the top left? Answer bank 10. Good job! Now let’s complete the rest of the initialize for the mouse. Grab a show from looks to make the mouse appear every new game and a wait 1 seconds from control. What values worked from the last page? 11. Now we will add the main loop for the mouse. We want the mouse to repeat code until it touches the cat. 12. We want to control the mouse using the mouse pointer. Why else would they call it a mouse pointer if it wasn’t used to point mice where to go? Joking! Let’s add these blocks. Each time the loop repeats we want the mouse to face the mouse pointer, go to the mouse pointer, and finally switch costume frames to look like the mouse is moving. 13. Let’s finish up with the mouse. It is time to add the mouse’s exiting code. The mouse will wait for a second before disappearing from the game. Control bubble Looks bubble 13. Select the cheese sprite. 🧀 14. The cheese doesn’t need any prep once the game starts. Cheese is always ready to go! Let’s add a hat block to start when the green flag is clicked and a forever loop from control for the main loop. Unlock the secret block by reading! A forever loop never stops. It does something forever, and ever, and ever… 15. Inside the forever loop we will add a wait until touching mouse. This is like a wait 1 second block but Scratch doesn’t move past this block until the mouse is touching the cheese. Wait until can be found in the control bubble and touching is in the sensing bubble. 16. Now click the sounds tab on the top left! 17. Click the speaker icon on the bottom left. 18. In the search bar type chomp and add the Chomp sound to the cheese. 19. Click back on the code tab. 20. Let’s add a start sound Chomp and a go to random position inside the forever loop. You can use the triangles by the sound to select Chomp. Test of skills or trial and error. Can you add background music to this game? You will have to add another sound and use those three blocks from the last project. Here is a hint. Good Job Ninja! You completed your fourth lesson. May the fourth be with you. Anyways, I think you’re catching up to things. Maybe the next project my puns won’t be so cheesy. You can make the game easier or harder by adjusting the amount of steps in the cat’s move steps block. Project 5: March Madness Concepts: Control | Operators | Variables Video Links! Are you ready to score some variables? A variable is like a basket that can hold data. That data can be a name, number, or more. 1. Click this link to open up project 5. 2. Click the remix button.
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-