100% found this document useful (1 vote)
2K views29 pages

Scratch Tutorial PDF Flying Cat and Rocket Landing

The document provides instructions for building a collecting game in Scratch where players help Space Cat collect crystals. It outlines adding a scrolling background, moving Space Cat with arrow keys, spawning random crystals that move and are collected to increase score. It ends with displaying a 'Game Over' message when crystals are missed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views29 pages

Scratch Tutorial PDF Flying Cat and Rocket Landing

The document provides instructions for building a collecting game in Scratch where players help Space Cat collect crystals. It outlines adding a scrolling background, moving Space Cat with arrow keys, spawning random crystals that move and are collected to increase score. It ends with displaying a 'Game Over' message when crystals are missed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

a tutorial series on

Space Cat game


Space Cat
Space Cat is on a mission to collect as many crystals as possible to
fuel his spaceship! Using the Scratch platform, you can build a fun
collecting game to help Space Cat with their mission. Collecting is a
popular mechanic in games and can be easily coded in Scratch with
the same basic logic. From weapons to badges, collecting can keep
players striving to achieve more in your game.
In this game, the goal is to collect as many crystals as possible, but if
you miss three crystals the game ends. This tutorial shows you how to
code this game from start to finish and you can cutomize it with your
own images and messages.

Table of Contents

Step 1 Create a new project 4


Step 2 Add scrolling background 5-6
Step 3 Add flying cat and move it 7
Step 4 Show random crystals and move them 8-9
Step 5 Add up losing crystals 10
Step 6 Increase score for gaining crystals 11-12
Step 7 Show “Game Over” screen 13-14
Complete Game 15

2
Code this game and see
how many crystals you can collect!

What you need:


1. Scratch account: Create a free Scratch account
2. Starter files: Download the images we are using in our game.
You can also use your own images to customize your application.

Download starter file

No coding experience necessary for this tutorial.


Beginner-friendly for ages 8 and up. Give it a try!
3
Step 1: Create a new Scratch project

Let’s start by creating a new project.

■ Visit https://scratch.mit.edu
■ Login to your account
■ Click on the “Create” button

Now, we can code your Flying Space Cat game!

Hint: You can also remix this project


and others to see the code.
4
Step 2: Add scrolling background

To give the effect of moving through space,


we created a simple scrolling background.

■ 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.

The stars will move while the backdrop stays in place.

■ Click upload sprite and upload the stars.png file


■ Change the size of the Stars sprite to 50 and position it on the screen
■ Add the “When Green Flag Clicked” block from the “Events” category
■ Use a “Forever” block with the “Go to Back Layer” block to make sure the stars show behind
other sprites.
■ Then, use a “show” block to make the stars visible
■ Position them with the “go to” block and use the “glide” block to move it left for 10 seconds.
■ “Hide” the sprite when it reaches the edge of the screen and the forever block will start this
animation over again.

5
Step 2: Add scrolling background

Hint: Add more images or use a different image


than stars. png to customize
your scrolling background.
6
Step 3: Add flying cat and move it

Let’s position our flying cat and add the logic


to move it up and down with arrows.

■ Select “Choose a Sprite”, find the Cat flying sprite, and


click to add it
■ Use the “Go to” block to position the sprite at x= -150 y=0
■ Add music with the “Forever” and “Play Sound Until
Done” block. We’re using the Dance Magic sound which
you can add in the Sounds tab.

Now, add logic to the arrow keys so our cat moves up and down when we click.

■ Under events choose the “when key pressed”


block and select “up arrow”
■ Underneath use a “change y by” block and
enter 5 to move up
■ Go back to events, choose the “When key pressed”
block and select “down arrow”
■ Underneath use a “change y by” block and
enter -5 to move down

Hint: Change the music by adding more sound options in the


“Sounds” tab. Then select them in the “play sound” block.
7
Step 4: Show random crystals and move them

We want random crystals to appear on the right side


of the screen and move towards the left.

■ 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

Hint: Select a different sprite


or draw your own sprite
to customize your collection item.

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

Everytime our flying cat touches a crystal, we want to increase our


score. In addition to increasing the score, we will also decrease the
count of the crystal variable. We do this because even though we
are hiding the crystal, it still touches the edge each time.
■ Go to the “variables” blocks and “Make a variable”, name it Score. Keep it checked so it shows
on your game screen.
■ Add the “When Green Flag Clicked” and set the Score to 0
■ Next, add a “Forever” block underneath

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

Your game is almost complete! Let the players know when


the game is over by showing a game over screen.
This will trigger when you’ve missed three crystals.

■ 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.

See complete Flying Space Cat game.

https://www.codewizardshq.com/scratch-tutorial-for-kids-flying-space-cat/

More Scratch Tutorials for Kids


■ Valentine’s Day Card Scratch Tutorial
https://www.codewizardshq.com/scratch-coding-for-kids-valentines-card-2021/

■ Holidays Advent Calendar Scratch Tutorial


https://www.codewizardshq.com/scratch-coding-for-kids-holiday-2020/

■ Halloween Candy Collector Game Scratch Tutorial


https://www.codewizardshq.com/scratch-coding-for-kids-halloween-2020/

■ How To Make a Game on Scratch


https://www.codewizardshq.com/how-to-make-a-game-on-scratch/
15
a tutorial series on

Rocket Landing game


Rocket Landing game
Scratch coding for kids is one of the easiest and most fun ways to get
started with learning to code. Kids can easily experiment in Scratch’s
drag-and-drop platform or take a Scratch coding class to build their
skills. Try this simple Scratch tutorial for kids for an introduction to
coding in Scratch.

Table of Contents

Step 1 Create a new project 4


X, Y positioning in Scratch 5
Step 2 Add a space backdrop 6
Step 3 Add a Rocketship sprite 7
Step 4 Move the Rocketship sprite 8
Step 5 Add the platform sprite and move it 9
Step 6 Add “Game Over” sprite 10
Step 7 Add “You Win!” sprite 11
Step 8 Add game logic to rocketship 12
Step 9 Add game logic to “You Win!” and “Game Over” 13
Complete Game 14

2
Complete this easy Scratch coding tutorial
to build your own trick or treat candy collector game.

What you need:


1. Scratch account: Create a free Scratch account

No coding experience necessary for this tutorial.


Beginner-friendly for ages 8 and up. Give it a try!

3
Step 1: Create a new Scratch project

Let’s start by creating a new project.

■ Visit https://scratch.mit.edu
■ Login to your account
■ Click on the “Create” button

Now, we can code your Rocket Landing game!

Hint: You can also remix this project


and others to see the code.

4
X, Y positioning in Scratch

Before we move on, let’s talk about x and y coordinates.


In Scratch, your images are called sprites.

Scratch uses x, y coordinates to position sprites on the screen.


You might have seen these in math class.
■ x coordinate – a number of pixels along the horizontal axis of a display starting from the pixel
(pixel 0) in the center of the screen.
■ y coordinate – a number of pixels along the vertical axis of a display starting from the pixel (pix-
el 0) in the center of the screen.
We’ll use these (x, y) coordinates to position our sprites and change these coordinates to move them.

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

Hint: Get creative! Choose any backdrop


you want from the library or
upload your own.

6
Step 3: Add a Rocketship sprite

Let’s create our player sprite by choosing the rocketship.

■ 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.

■ Click on the “Code” tab


■ Add the “When Green Flag Clicked” block from the “Events” category
■ Position your rocketship at the top of the screen using a “Go to” block
■ Now, click on the green flag to position your sprite

Hint: You can also upload your own Spaceship


or use the “Paint” option to draw one.

7
Step 4: Move the Rocketship sprite

To move our rocketship right and left using arrows,


we will use “Events” blocks.

■ 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

We also want our rocketship to move down towards the platform.

■ Add another “When Green Flag Clicked” block


■ Use a repeat block to repeat the downward motion of the
rocketship 200 times
■ Move the rocketship down the y-axis (top to bottom) with a
“Change by” block

Hint: Change the 5 and -5 values to move your rocketship


more or less with each click
8
Step 5: Add the platform sprite and move it

Let’s create a moving platform to land our spaceship.

■ 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

We need some text to tell us when the game is over.

■ Click on the cat icon, select “Paint”


■ Select the rectangle option to draw a black rectangle
■ Then, select the text option and type “Game Over” in yellow on top of the rectangle
■ Right click on the sprite to rename it “Game Over”
We only want this sprite to show if our rocketship reaches the bottom.
Go back to the code tab to add code to this block.

■ Add the “When Green Flag Clicked” block


■ Use “Hide” block to hide the block until we need to show it

Hint: Use the text option to write any message


you want when the game is over.

10
Step 7: Add “You Win!” sprite

We also need some text to tell us when we’ve successfully landed.

■ Right click on the “Game Over” sprit and duplicate


■ Click on the “Costumes” tab to edit the text
■ Double click the text and type “You Win!”
■ Right click to rename this sprite “You Win”

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.

Hint: Change the color of the box and the text


to personalize your message.
11
Step 8: Add game logic to rocketship

Depending on where the rocketship lands, we will display


a different message. We need to broadcast the information
to the other sprites get the right message.
■ Click on the Rocketship sprite
■ Underneath the “Go to” block add a forever loop
■ Inside the forever loop, add two “If-then” controls
■ If the rocketship touches the edge, use the broadcast block
and create a new message called “Lose”
■ If the rocketship touches the platform block, use the broadcast block
and create a new message called “Win”

12
Step 9: Add game logic to “You Win!” and “Game Over”

Depending on where the rocketship lands, we will display


a different message. We need to broadcast the information
to the other sprites get the right message.

■ Click on the “Game Over” sprite


■ Use a “When I receive” block and select the “Lose” message
■ When this message is received, show the message
and stop all scripts

Do the same thing for the “You Win!” sprite

■ Click on the “You Win!” sprite


■ Use a “When I receive” block and select the “Win” message
■ When this message is received, show the message
and stop all scripts

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.

Play Rocketship Landing game.

https://www.codewizardshq.com/scratch-tutorial-for-kids/

More Scratch Tutorials for Kids


■ Valentine’s Day Card Scratch Tutorial
https://www.codewizardshq.com/scratch-coding-for-kids-valentines-card-2021/

■ Holidays Advent Calendar Scratch Tutorial


https://www.codewizardshq.com/scratch-coding-for-kids-holiday-2020/

■ Halloween Candy Collector Game Scratch Tutorial


https://www.codewizardshq.com/scratch-coding-for-kids-halloween-2020/

■ How To Make a Game on Scratch


https://www.codewizardshq.com/how-to-make-a-game-on-scratch/ 14

You might also like