How to Make Rock Blaster Game on Scratch? | A Step-by-Step Tutorial [+Free game code]

Contents
importance of scratch programming

Scratch games are visually fun and interactive ways of learning coding and game development, especially for children between the ages of 8 to 16. A rocket blaster game on Scratch can be of different types depending on the sprite’s movement, objective, and rewards.

In this blog, we will give you a step-by-step tutorial on how to create a rock blaster game on Scratch.

What is a rock blaster game on Scratch?

A Rock blaster game is a game where you [the player] control the rocketship and fire the laser to blast the space rock. Above, you can see a rocketship shooting a laser, and if the laser touches the rock, the rock blasts, and the score will increase by 100. Using the up and down arrow keys, you can control the direction of the rocketship in the up and down order. 

The rock blaster game-making process can be broken down into 5 steps as below:

  1. Pick the sprite [rocketship]
  2. Control the sprite [with up and down arrow keys]
  3. Add the enemies [rocks]
  4. Shoot the laser [sprite]
  5. Keep score

How to make a rocket blaster game in Scratch? – Step-by-step guide

The step-by-step guide on creating the flying game on Scratch is explained below:

Step 1: Pick the sprite [Rocketship]

Let’s pick a spaceship sprite for the game.

  • First, delete the Cat sprite.
scratch cat sprite
  • Click on “Choose a Sprite”
choose a sprite
  • Search rocketship and click on it.
rocketship sprite
  • Rocketship added
scratch rocketship sprite
  • Change the size and direction of the “rocketship” as shown below. 
Change the size and direction of the “rocketship”
  • Let’s choose a backdrop for the game. Click on “Choose a Backdrop”
choose a backdrop
  • Type and search “Stars” and click on it.
stars backdrop
  • Star backdrop added
star backdrop added

Step 2: Control the sprite [with Up & Down arrow keys]

  • As we want to move the rocketship in up & down order we have to do that by changing the y value.
  • Drag & drop the “change y by” block from the “motion category” positive y value will move upward, and the negative y value will move downward.
rock blaster game on scratch
  • Control rocketship with up & down arrow keys.
  • Write a conditional statement to determine whether the “up arrow” key is pressed or not.
  • Drag and drop the “if-then” block from the “Control” category as shown below.
Drag and drop the “if-then” block
  • From the “sensing category” drag and drop the “key pressed?” block and click on the drop-down and select “up arrow” as shown below.
drag and drop the “key pressed?”
  • Similarly, write a conditional statement for the “down arrow” key as shown below.
write a conditional statement
  • To check the condition continuously whether the up-arrow and down-arrow key is pressed or not put this code in the “forever” loop.
rock blaster game on scratch
  • Click on “forever” as shown below.
  • You can control the rocketship in upward  & downward order using the up & down arrow keys.
rock blaster game on scratch
  • Make a starting point for the rocketship when the game start. 
  • Drag & drop the “go to x y” block and set the value (-178, 5).
  • Drag & drop the “when green flag clicked” block on top as shown below.
Drag & drop the “when green flag clicked”
  • Click on
  • Rocketship comes to the start point (-178, 5) when the game start.
rock blaster game on scratch

Step 3: Add the enemies [rocks]

Now, let’s add an enemy sprite [rock] to the game.

  • Click on “Choose a Sprite”
choose an enemy sprite
  • Type rock and click on it.
select rock sprite
  • Rock sprite added.
rock sprite added
  • To make the game design cool, reduce the size of your sprite rock. Also, set the direction 90 as shown below.
  • Place the rock on the right side of the rocketship because the rock should come from right to left.
Place the rock on the right side of the rocketship
  • Make multiple rocks that will come as enemies. In Scratch, using clone, we can do this.
  • First, make it visible when the game start.
  • Drag & drop “when green flag clicked” and “show” blocks as shown below.
Drag & drop “when green flag clicked” and “show” blocks
  • Let’s make five clones of rock. 
  • Drag & drop the “repeat” loop and run it five times. 
  • Drag & drop the “create a clone of myself” block as shown below.
create a clone
  • After this drag and drop a “hide” block as shown below.
clone created
  • Click on
  • You can see five clones of rock created.
5 clones created
  • In Scratch, you can program the clones using “when I start as a clone”?
  • Let’s write the code when rocks started as a clone.
  • Drag and drop the “when I start as a clone” block.
Drag and drop the “when I start as a clone” block.
  • Set the clone position when they started as clones.
  • Drag & drop the “go to x y” block and set the (x, Y) coordinates.
  • Set x 240 to the right edge of the stage area, and make the y value random so that the rock comes from a random height.
  • Drag and drop the “pick random to” block as shown below.
Drag and drop the “pick random to”.
  • Click on
  • You can see rocks appear on the right edge of the stage and at random heights.
  • But rocks are not moving towards the rocket ship. 
rock blaster game on scratch
  • To move the rocks towards the rocketship change the rock’s x position by negative values.
  • First, add a conditional loop to check whether the rocks touch the rocket ship.
add a conditional loop
  • Drag & drop the “change x by” block as shown below.
  • Set the x value by -5; this value will decide how fast rocks come toward the rocket ship.
Set the x value by -5
  • Click on
  • Now, rocks can move toward the rocket ship.
  • But rocks are stuck at the left edge of the stage and should go back to the right edge once they touch the left edge of the stage. 
rocks moving toward rocket
  • Write a conditional statement to determine whether rocks touch the left edge of the stage.
  • Drag and drop “if-then” and “less than” blocks as shown below.
Drag & drop “if-then” and “less than
  • Drag & drop the “x position” block to the “less than” block as shown below.
  • Set the threshold x value -220 (just after rocketship)
Set the threshold x value -220
  • If rocks touch the left edge of the stage then move the rocks to the right edge of the stage.
  • Drag & drop the “go to x y” block and set the (x, Y) coordinates.
  • Set x 240 to the right edge of the stage, and make y value random so that the rock comes from a random height.
  • Drag and drop the “pick random to” block as shown below.
Drag and drop the “pick random to”
  • Click on
  • Now, rocks can go back to their original position (right edge of the stage) it touches the left edge of the stage.
  • But all rocks come at the same speed every time. To enhance the game, let’s make it random. 
rock blaster game on scratch
  • First, create a variable
  • Click on the “Variables” category, then click on “Make a Variable” 
make a variable
  • Name your variable and click on “Ok”
name the variable
  • Speed variable created.
  • Drag & drop the “set speed to” block as shown below.
rock blaster game on scratch
  • To make the rock move at speed random, drag & drop “pick random to” block to “set speed to” block and set the value -2 to -6; you can choose any.
  • Now random rock speed is stored in the “speed” variable.
rock blaster game on scratch
  • Drag & drop the “speed” variable to the “change x by” block as shown below.
rock blaster game on scratch
  • Click on
  • Rocks come at different speeds.
rock blaster game on scratch

Step 4: Shoot the Laser [Sprite]

Now, let’s add the laser sprite (bullets) to the rocket ship that will be used to blast the rock.

  • Click on “Choose a Sprite”
rock blaster game on scratch
  • You can choose any but let’s select something rectangular because by reducing their size, it will look like laser/bullets. 
  • In Scratch, you can use “Button2”, so search and click on it.
rock blaster game on scratch
  • Rename the “Button2” sprite and set the size 10.
rock blaster game on scratch
  • Make the rocketship shoot a laser/bullet by pressing the spacebar key.
  • Drag & drop “when space key pressed” and “create clone of myself” blocks as shown below.
rock blaster game on scratch
  • Click on
  • By pressing the “spacebar” key laser clones are created.
rock blaster game on scratch
  • Make laser clone sprites start from the rocketship so that it can seem like a bullets/laser shoot.
  • Drag & drop “when I start as a clone” and “go to x y” blocks as shown below
  • Set the x position to -160 (on rocketship) and make the rocks y position to the same rocketship y position.
  • You can do that using “backdrop# of Stage” from the “sensing” category. 
rock blaster game on scratch
  • Drag the “backdrop# of Stage”  from the “sensing” category. 
rock blaster game on scratch
  • Drop the “backdrop# of Stage” block and change “Stage” to “Rocketship”. 
rock blaster game on scratch
  • And, change “backdrop” to “y position”.  
  • Now, add a conditional statement loop till laser clones touch the stage edge.
  • Drag & drop “repeat until” and “touching edge?” blocks as shown below. 
rock blaster game on scratch
  • Till the laser clones touch the stage edge move the laser.
  • Drag & drop the “move steps” block shown below.
rock blaster game on scratch
  • Click on
  • Rocketship can shoot the laser. 
  • But the first laser is neither moving nor disappearing. 
rock blaster game on scratch
  • Drag & drop “when green flag clicked” and “hide” blocks as shown below.
  • Also, delete the laser clones when they touch the edge.
  • Drag & drop the “delete this clone” block as shown below.
rock blaster game on scratch
  • Click on
  • The rocketship can move up and down using the up and down arrow keys, and if you hold down the spacebar key, it shoots lasers, which end up once the lasers reach the edge. 
  • But nothing is happening if rocks touch the rocketship and the laser touches the rocks.
rock blaster game on scratch
  • Click on the “Rocks” sprite to program it.
rock blaster game on scratch
  • Write a conditional statement to determine whether rocks touch the laser.
  • Drag & drop “if-then” and “touching laser” blocks as shown below.
rock blaster game on scratch
  • Drag & drop the “go to x y” block and set the (x, Y) coordinates.
  • Set x 240 to the right edge of the stage, and make y value random so that the rock comes from a random height.
  • Drag & drop the “pick random to” block as shown below.
rock blaster game on scratch
  • Click on
  • Now, if the laser touches the rocks, the rocks are destroyed.
  • But nothing is happening if the rocketship touches the rocks.
rock blaster game on scratch
  • Let’s stop the game if the rocketship touches the rocks.
  • Drag & drop the “stop all” block to the end of the “repeat until” loop because this loop only ends when the rocketship touches the rocks.
rock blaster game on scratch
  • To enhance the game let’s add a sound effect when the game gets over (stop all).
  • Click on the “Sounds”
scratch sound
  • Click on the “Choose a Sound”
scratch sound
  • Search “lose” and click on it.
scratch sound
  • Get back to the code, click on the “Code”
rock blaster game on scratch
  • Drag & drop the “play sound Lose until done” block as shown below.
rock blaster game on scratch
  • Click on
  • Now, if the rocketship touches the rocks, the game stops with a sound. 
rock blaster game on scratch

Step 5: Set the score

  • Let’s add the score to the game when the rocketship shoots the rocks. 
  • Create a variable to keep track of the score.
  • Click on the “Variables” category and click on the “Make a Variable”.
rock blaster game on scratch
  • Name your variable
rock blaster game on scratch
  • Change the score by 100 when the laser touches the rock.
  • Drag & drop “change score by 100” as shown below.
rock blaster game on scratch
  • Let make score zero when the game start.
  • Drag & drop the “set score to” block as shown below and set its value to zero.
rock blaster game on scratch
  • Click on
  • When you shoot the rock you will get a score of 100.
rock blaster game on scratch
  • Let’s add a sound when the score increase by 100.
  • Click on “Sound” and click on “Choose a sound”.
  • Search “magic spell” you can choose any, and click on it. 
scratch sound
  • Drag & drop the “start sound Magic Spell” block as shown below.
rock blaster game on scratch
  • Click on
  • A sound will play on each score gain.
rock blaster game on scratch
  • Now you are done. 
  • Click on and enjoy your game.
rock blaster game on scratch

Time to Play!

  • Congratulations, You have completed the Rock blaster game in Scratch!
  • Click on “green flag” to start playing the Rock blaster. What are the enhancements to the game you can think of? Do let us know in the comments section below.

Frequently asked questions (FAQs)

How to make a rock blaster game on Scratch?
To make the rock blaster game on Scratch follow the below steps:

  1. Pick the sprite [rocketship]
  2. Control the sprite [with up and down arrow keys]
  3. Add the enemies [rocks]
  4. Shoot the laser [sprite]
  5. Keep score

What is the rock blaster game on Scratch?
The rock blaster game on Scratch is where the spacecraft shoots out lasers and attacks oncoming rocks. If the laser toches the rock then the rock blasts and the score increases by 100 if the rock touches the spacecraft then it is game over.

What is the coolest game on Scratch?
Some of the coolest games on Scratch are Pokemon clicker, Flip 3D, Fortnite Z, Ball blast, Old western way, and many more!

What is the easiest game to code on Scratch?
The Maze game is the easiest game to code on Scratch.

We hope the tutorial has helped you in creating a rock blaster game on Scratch! Want to make more such games? Check out our beginner-friendly guide to Scratch games.

Get 1-on-1 online Scratch classes

Related Posts

Company

Contact

Email:

info@wiingy.com

+(1) 618-827-5802

About Wiingy

Wiingy provides 1-to-1 online tutoring, instructor-led online technology courses, and web tutorials to school students, university students, and working professionals across the globe.

Wiingy works with top verified, qualified, and experienced instructors to deliver online lessons in Coding, Math, Science, and over 50 other subjects.

Parents and students have rated the teaching experience as 4.8/5 and above.

We are a community of over 20,000 students across 10+ countries growing daily.

Copyright Wiingy Pvt Ltd © 2021. All Rights Reserved

Do you want to learn from
Verified, Qualified, and Experience Online Tutors
backed by Wiingy's Perfect Match Guarantee?