Scratch Tutorial PDF Flying Cat and Rocket Landing
Scratch Tutorial PDF Flying Cat and Rocket Landing
Table of Contents
2
Code this game and see
how many crystals you can collect!
■ Visit https://scratch.mit.edu
■ Login to your account
■ Click on the “Create” button
■ Start by deleting the Scratch cat sprite that appears in every new project.
Click on the cat sprite and the trash can icon.
■ Click the “Choose a Backdrop” icon and add the “Galaxy” backdrop.
5
Step 2: Add scrolling background
Now, add logic to the arrow keys so our cat moves up and down when we click.
■ Select “Choose a Sprite”, find the Crystal sprite, and click to add it
■ Add the “When Green Flag Clicked” and a “Forever” block underneath it to repeat the move-
ment of the crystals
■ Go to the “variables” blocks and “Make a variable”, name it Y-Position and uncheck it
■ Inside the “forever” block “show” the crystal and set to a random position on the right side
using “go to x” with x=240 and y=y-position
■ Then, glide 2 seconds to x=-240 and y=y-position
■ Use “set” y-position to a random number between 100 and -100, so it shows up in a
different position next time
■ “Hide” the crystal then wait a random amount of time between 1 and 2 seconds to
repeat the loop
8
Step 4: Show random crystals and move them
9
Step 5: Add up losing crystals
When a crystal flies by us and we don’t catch it, we want to count it.
When we reach 3 crystals, the game is over.
Let’s add on to the code you started in Step 4.
■ Go to the “variables” blocks and “Make a variable”, name it Crystal and uncheck it
■ Under “when green flag clicked” set the Crystal variable to 0
■ Create an “if” blocked with the condition “touching edge”.
■ Inside this “if” block, change the crystal variable by 1. Add it under the “hide” block. Now each
time it touches the edge, we add one.
■ Add another “if” block inside the first “if” block. Use the condition “crystal = 3”.
■ Then we will broadcast a new message named “Game Over”
■ Add a “stop all” block to stop the game once the number of crystals reaches 3.
Hint: You can give different names to your variables, just make
sure you are using the right variable in your code.
10
Step 6: Increase score for gaining crystals
Inside the forever block, we will add the game score for every time our cat touches a crystal.
■ Use an “if” block with the condition “touching cat flying” sprite
■ Add the “start sound” block and select “magic spell” for a sound effect
■ Then change the score variable by 1 and the crystal variable by -1
■ Hide the crystal once it’s collected
11
Step 6: Increase score for gaining crystals
12
Step 7: Show “Game Over” screen
■ Select “paint” under sprites and rename this sprite Game Over.
■ In the costumes tab, select the rectangle tool and click and drag to draw a rectangle
■ Then, use the type tool with font “marker” and add the message “Game Over”
■ Adjust the message on your game screen
13
Step 7: Show “Game Over” screen
■ Go back to the “Code” tab
■ Add the “When Green Flag Clicked” and hide block. That means this message will not show when
the game starts
■ Add the “receive broadcast” block and select game over. This is the message we sent from the
crystal sprite when the crystal variable reached 3.
■ Then, add the “stop all” block to end the game.
Hint: You can change the font, colors, and text for your
Game Over message in the “Costumes” tab.
14
Your Flying Space Cat game is all done!
Click the green flag and give it a try. If you want to let other people
see your project and remix it, click the “Share” button at the top.
https://www.codewizardshq.com/scratch-tutorial-for-kids-flying-space-cat/
Table of Contents
2
Complete this easy Scratch coding tutorial
to build your own trick or treat candy collector game.
3
Step 1: Create a new Scratch project
■ Visit https://scratch.mit.edu
■ Login to your account
■ Click on the “Create” button
4
X, Y positioning in Scratch
5
Step 2: Add a space backdrop
A new project will open up and you will see the Scratch interface.
■ Start by deleting the Scratch cat sprite that appears in every new project.
Click on the cat sprite and the trash can icon.
■ Click the “Choose a Backdrop” icon and add the “Space” backdrop.
■ Click on the “Create” button
6
Step 3: Add a Rocketship sprite
■ Select “Choose a Sprite”, find the Rocketship sprite, and click to add it
■ In the “Costumes” tab select costume 5
■ Decrease the size of your Rocketship to 50
In order to run our code in Scratch, use the “When Green Flag Clicked” block to get started.
7
Step 4: Move the Rocketship sprite
■ Add the “When space key pressed” block and change the
dropdown to “left arrow”
■ Underneath that, add a “Change x by” block and use -5 to
move left
■ Next, add the “When space key pressed” lock and change
the dropdown to “right arrow”
■ Underneath that, add a “Change x by” block and use 5 to
move right
■ Select “Choose a Sprite”, find the Paddle sprite, and click to add it
■ Right click on the sprite and rename it to Platform
■ Position the Platform so y = -175, at the bottom of the screen
We want our platform to move randomly, so we need a variable to hold a random x value.
To add code, go to the “Code” tab.
■ Go to Variable blocks and right click on the orange variable circle and rename it “New-X”
■ Add the “When Green Flag Clicked” block
■ Use a forever loop to keep the platform moving
■ Inside the forever loop, set the “New-X” variable to a random number between -240 and 240
■ Use a “Glide” block and use the “New-X” value for x and -175 for y
9
Step 6: Add “Game Over” sprite
10
Step 7: Add “You Win!” sprite
We only want this sprite to show if our rocketship touches the platform. Since we duplicated this
sprite, it should already have the code to hide the block when the green flag is clicked.
12
Step 9: Add game logic to “You Win!” and “Game Over”
13
Your Rocket Landing game is complete!
Click the green flag and give it a try. If you want to let other people
see your project and remix it, click the “Share” button at the top.
https://www.codewizardshq.com/scratch-tutorial-for-kids/