Scratch Archives - CodeWizardsHQ The leading online coding academy for kids and teens ages 8-18 Mon, 16 Dec 2024 07:46:18 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 https://www.codewizardshq.com/wp-content/uploads/2019/10/cropped-cropped-blueHorizontal-32x32.png Scratch Archives - CodeWizardsHQ 32 32 Fun Ways to Use the Pen Tool in Scratch https://www.codewizardshq.com/fun-ways-to-use-the-pen-tool-in-scratch/ Mon, 16 Dec 2024 07:27:31 +0000 https://www.codewizardshq.com/?p=67099 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

The Scratch pen tool is a fun extension to any Scratch project and teaches kids about conditionals and events. Scratch coding is a great way to introduce fundamental coding concepts to kids and teens. Once they have the basics down, Scratch is powerful enough to make robust apps and games. The pen tool is especially […]

The post Fun Ways to Use the Pen Tool in Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

The Scratch pen tool is a fun extension to any Scratch project and teaches kids about conditionals and events. Scratch coding is a great way to introduce fundamental coding concepts to kids and teens. Once they have the basics down, Scratch is powerful enough to make robust apps and games. The pen tool is especially great for creative and drawing projects.

Kids who want to dive in and develop their Scratch skills can learn live from expert instructors. Take a look at our top-rated Scratch classes for kids.

In this article, I’ll show you how to setup the pen tool and creative ways to use it in your project.

What does the pen tool do? 

The Pen tool acts like a digital pen where users can draw, create patterns, and make interactive graphics directly on the Scratch canvas. A mouse or a sprite acts as a pen and draws a line from its center. The Pen can be used to draw simple shapes and lines all the way up to using loops and conditionals to draw complex images and patterns. 

It’s a fun way for kids to enhance their projects. My students especially enjoy the pen projects because they love being able to draw freehand. The Pen tool is often used for creative projects, such as designing art, animating visual effects, or building interactive activities like drawing apps.

Set Up the Pen Tool in Scratch

The Pen blocks are not one of the standard blocks in Scratch so it needs to be added as an extension. To do that, follow these simple steps:

  1. Visit scratch.mit.edu
  2. Login to your Scratch account
  3. Click on the Create button
Create a new Scratch project
  1. Under the blocks, click Add an Extension
Add a scratch Extension
  1. Select Pen
pen tool

Once you’ve applied the extension, you should see a new set of blocks in the block palette called Pen. These blocks will control the Pen application in your project.

see the new pen blocks

Pen Blocks in Scratch

There are a just a handful of Pen blocks, but they can accomplish a lot! 

  • erase all
  • stamp
  • pen up
  • pen down
  • set pen color to [color]
  • change pen color by [number]
  • set pen color to [number]
  • change pen size by [size]
erase all block

erase all: Clears all drawings made with the pen tool on the stage. It erases everything drawn without affecting the backdrop or sprites themselves

stamp block

stamp: Copies the current look of the sprite onto the stage as a static image. It’s often used with “Pen Down” and “Pen Up” to create patterns, tiled images, or animated scenes.

pen up block

pen up: Lifts the pen off the stage, stopping any drawing until “pen down” is used again. This is helpful for moving a sprite without drawing a line.

pen down block

pen down: This command starts drawing whenever the sprite moves. It’s used to make continuous lines as the sprite moves across the stage.

set pen color black

set pen color to [color]: Allows users to change the color of the pen. This is often used to add colorful designs and drawings.

change pen color block

change pen color by [number]: Adjusts the current color of the pen by a specific value, which can create color gradients or rainbow effects as the sprite draws.

set pen color to block

set pen color to [number]: Adjusts the current color of the pen by a specific value, which can create color gradients or rainbow effects as the sprite draws.

change pen size block

change pen size by [size]: Sets the thickness of the pen line. Larger values make thicker lines, which can be useful for emphasizing parts of a drawing.

set pen size block

set pen size to [size] Sets the thickness of the pen line. Larger values make thicker lines, which can be useful for emphasizing parts of a drawing.

Fun Ways to Use the Pen in Scratch

Using the pen tool is kind of like drawing on paper, with a twist. By combining the pen blocks with loops, variables, and other blocks, kids can create all kinds of art and animations. These are just some of the cool things you can do with the pen tool. 

  • Draw freehand
  • Draw shapes with math
  • Customize pen colors/width
  • Use variables
  • Animation
  • 3D
  • Using loops with the pen tool

Draw Freehand

You can use any sprite as a pen and draw with it. If you want it to look like you’re drawing with your mouse, simply hide the sprite. This code allows you to draw when your mouse is clicked. You can also set the pen color and size. 

draw freehand block

Example project: Paint App

Our student, Kiera, created this simple painting app where the user can make multiple brush selections.

paint app project in Scratch

View project

Draw Shapes (with Math)

There are several ways to draw shapes using the pen tool. You can simply use a series of blocks to guide your sprite. Using math, you can build shapes quickly and easily.

To create any shape you need to know:

  • Number of sides: Decide how many sides your shape will have (e.g., 3 for a triangle, 4 for a square).
  • Angle to turn: Calculate the angle for each turn using the formula: Angle=360∘/Number of sides

For example, this code will draw a triangle with 3 sides that are each 100 pixels. The number of sides is 3 and the angle to turn is 120. Set your sprite to start at the beginning of the shape.

Drawing shapes block

Example project: Pen Shape Drawer

In this app, users can choose the number of shapes, sides, and the size of the lines to generate a drawing. 

Pen shape project

View project

Customize pen colors and size

Add your own style and creativity to your project by customizing the pen color and sizes. You can use the “set pen color to” block with an RGB color and “set pen size to” block with a number of pixels. You can even use variables and loops to change these features as you’re drawing with the “change pen color to” and “change pen size to” blocks.

This code draws a 5px line in turquoise when the pen is down:

customize pen size and color

Example project: Pen Paint

The Pen Paint app uses buttons to controls the size and color of the pen to create beautiful drawings.

View project

Use variables

Using a variable makes your application more flexible and robust. Allow users to select the color and size for the pen dynamically. You can also change the color and size with code as you draw. By adding variables the possibilities are endless.

Set the pen’s thickness based on a number variable with this code:

Set pen variable
pen block with variables

Example project: Paint App

Our student, Kiera, created this painting app that takes user input and has buttons to create shapes with a click.

paint app project

View project

Animation

The pen tool can draw shapes and change the size and color of the pen dynamically. This makes it possible to create unique effects in your program. 

This code creates an ongoing circle animation using the pen tool:

animation code blocks

Example project: Pen Animation #1 Tutorial

Watch this colorful and entrancing animation that uses just a few pen blocks. 

pen animation project

View project

Using loops with the pen tool

You can use loops in combination with the pen tool to create cool drawings and effects. Create complex shapes using the loop blocks. This code repeats a hexagon drawing to create a unique new shape.

pen tool with loop

Example project: Fruit Ninja

Fruit Ninja is a student favorite where we cut the fruit using a line drawn with the pen tool. 

fruit ninja project

View project

3D Drawings

The pen tool can also be used to make 3D drawings. Even though Scratch doesn’t provide tools specifically for creating 3D art, a combination of existing blocks and the pen tool can help you create the illusion of 3D graphics.

One way is to create multiple layers with stamps, to create a 3d effect. We applied this to create a 3d block.

3d drawings blocks in Scratch

Example project: 3D Maze Rendering

Go beyond the flat 2D drawings and render 3D graphics with the pen tool.

3d maze rendering project

See project

Project Ideas Using the Pen Tool 

Do you need some inspiration for your first pen project? You’d be surprised at everything the pen tool can do. Check out some of the most loved Scratch pen projects:

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Learn to Code Games in Scratch 

The pen tool is just one type of extension in Scratch. Besides the basic blocks like Controls, Motion, and Variables, there are extensions that use artificial intelligence, text-to-speech, and video sensing. Kids can learn to code in Scratch with these extensions and more in our Elementary Schoool Core Track.

In our elementary school coding program, kids, ages 8-10, use Scratch to learn fundamental coding concepts. With a solid foundation in programming concepts, they can then advance to text-based languages like JavaScript and Python.

If you want support teaching your child to code, enroll in our top-rated Scratch coding classes.

The post Fun Ways to Use the Pen Tool in Scratch appeared first on CodeWizardsHQ.

]]>
How to Make a Maze in Scratch in 7 steps https://www.codewizardshq.com/how-to-make-a-maze-in-scratch-in-7-steps/ Mon, 18 Nov 2024 02:35:31 +0000 https://www.codewizardshq.com/?p=66538 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

A maze is a simple puzzle where you try to find your way from the beginning to the end. Completing a maze tests your memory, problem-solving skills, and patience. Coding does the same! Both require having to think logically and in order.   In this tutorial, I’ll show you an easy and fun way to code […]

The post How to Make a Maze in Scratch in 7 steps appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

A maze is a simple puzzle where you try to find your way from the beginning to the end. Completing a maze tests your memory, problem-solving skills, and patience. Coding does the same! Both require having to think logically and in order.  

In this tutorial, I’ll show you an easy and fun way to code a maze in Scratch where you control the player with your arrow keys. As a bonus, I’ll also teach you how to animate your character and add a timer. 

You can learn to build a maze and other fun Scratch games with a live instructor in our top-rated coding classes. My elementary school students really enjoy how engaging and easy Scratch coding is. They just have to drag and drop to create cool games and programs. By coding a maze, we’ll learn about loops, collision detection, and events. 

Complete this tutorial to code a maze Scratch!

Completed maze game

Play and remix the complete maze game now. 

In this game, the baby penguin, Pesto, has lost his hat. Mom is going to be mad! Help him find his winter hat to win.

We can break down this game into 3 main components: 

1. The maze: A drawing of a maze obstacle players have to avoid and make their way through.

  • Draw the maze

2. The player: the player, the penguin, moves around the maze and returns to the beginning when they touch the edge.

  • Add and position the player
  • Move the player around the maze
  • Detect player collision with the maze

3. The goal: the goal, the winter hat, is placed at the end of the maze and the player wins when they reach the goal.

  • Add and position the goal
  • Detect player collision with the goal

What you need:

Scratch account: Create a free Scratch account

No coding experience is necessary for this Scratch tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

Steps to Make a Maze Game in Scratch

Let’s turn each of the parts we discussed previously into steps:

  1. Create a new Scratch project
  2. Add a backdrop
  3. Draw the maze
  4. Add and position the player 
  5. Move the player around the maze
  6. Detect player collision with the maze
  7. Add and position the goal
  8. Detect player collision with the goal

Step 1: Create a New Scratch project

First, we need to set up a new project in Scratch where we will edit our code. 

  • Visit scratch.mit.edu
  • Login to your Scratch account
  • Click on the Create button
Create a new Scratch project
  • A new project will open, rename your project to Penguin Maze Game
  • Hover over the cat sprite and click the trash can to delete it
Name Scratch project Penguin maze game

Now we have a fresh new project to code our maze game!

Hint: You can also remix the Penguin Maze project to see the completed code.

Step 2: Add a Backdrop

Set the stage for your game by adding a background image.

  • Click the Choose a Backdrop button
Choose a backdrop button
  • Select the Arctic backdrop
select the arctic backdrop in scratch

You should now see the backdrop in your preview area. 

see the backdrop in Scratch preview

Hint: Get creative and select a backdrop that matches your theme. You can also select Surprise to let Scratch choose for you. 

Step 3: Draw the maze

A maze is simple to draw with just horizontal and vertical lines. We’ll draw our own maze, make sure you leave enough room for your player to get through. 

  • Hover over the choose a sprite button, select Paint
select paint button
  • Click on the line icon
  • Select an outline color and change the size of your lines to 20
  • Click and drag lines to represent the maze. Adjust it to fit the game preview.
outline maze sprite
  • Click the Code tab and rename the sprite to Maze.
rename the maze sprite

Do you see your maze in the preview screen like this? Great!

see the maze in the preview

Hint: You can make the maze as easy or hard as you want. Add more lines and dead ends to make the maze harder. 

Step 4: Add and position the player

We want to add our player, the penguin. The penguin is going to start at the top left every time the game starts. Before we move the penguin, position it at the top with our code.

  • Click the Choose a Sprite button in the right corner
choose a sprite button
  • Select the Penguin 2 sprite from the library
select the penguin sprite
  • Change the size to fit your maze, my penguin is 20.
change the penguin sprite size

Next, add this code to the penguin so that it goes to the starting position every time the game starts. 

  • Add a When green flag clicked block from events category.
  • Add Go to x y position block from motion category. Use the x and y value of your sprite at the starting position.
go to x y
see the penguin move

Now, try moving your player away from the starting position. When you click the green flag, it should return there. If your test works, you’re ready for the next step. 

Hint: You can get creative and draw your own sprite, just hover over the add a sprite button and go up to Paint.

Step 5: Move the player around the maze

The penguin is on the screen, but he can’t move. The penguin needs to move up, down, right, and left when we press the arrow keys. We need to control him with the arrow keys.

Let’s add the logic to the arrow keys. To move the sprite right and left, add this code: 

  • In the Events category, add When right arrow key pressed block
  • Add a Change x by block from the motion category and change the value to 10
  • Right click on When key pressed block and Duplicate the entire code block
  • Then change the dropdown to When left arrow key pressed and change x by to -10
when right or left arrow key pressed blocks

To move the sprite up and down, add this code: 

  • In the Events category, add When right arrow key pressed block
  • Add a Change y by block from the motion category and change the value to 10
  • Right click on When key pressed block and Duplicate the entire code block
  • Then change the dropdown to When left arrow key pressed and change x by to -10
when up or down arrow key pressed blocks
complete code for penguin movement

Your penguin can move now! Try pressing the arrow keys and make sure the penguin is moving in the right direction.

Hint: To move the player faster or slower, change the x and y values. 

Step 6: Detect player collision with the maze

We need to code what happens when the player touches the maze. The penguin should say ‘Oh no!’ and go back to the starting position.

  • On the player sprite, add a Forever block.
  • Inside the Forever block, add an If then block
  • From the sensing category, add the Touching block inside the if then block. Change the dropdown to the Maze sprite.
  • From the looks category, add a say block and update the message to “Oh no!”
  • Finally, add a go to block and use the same x y position as the starting position 
detect a collision with if then block
detect a collision final code

Now, you can try touching the maze with your player sprite. Does it return to the starting position?

It’s working, let’s keep going! 

Hint: You can customize the message your sprites says or change what happens after the sprites touch. 

Step 7: Add and position the goal

Our player is in place and can move around the maze. Now, let’s place the goal at the end of the maze. 

  • Click the Choose a Sprite button in the right corner
  • Select a sprite from the library. I’m using one from the Scratch library called Winter Hat.
choose the winter hat sprite
  • Change the size to fit your maze. Mine is size 40.
change your maze to size 40
  • Add a “when green flag clicked” block
  • In the preview, position the hat at the end of the maze. Then add a Go to x y position block using those coordinates. Mine is positioned at x = 195 and y = -135.
position the hat
position the hat code

Once you’re done, click the green flag to test your game. Your hat should go to the end of the maze when the green flag is clicked.

Hint: You can customize the goal sprite to fit your theme by drawing or uploading a sprite.

Step 8: Detect player collision with the goal

To win the game, the player needs to reach the goal. When the player teaches the goal, they say “I found it!” and the game ends.

  • On the player sprite, inside the forever block, add an if then loop
  • From the sensing category, add the Touching block inside the if then loop. Change the dropdown to “Winter Hat”
  • Add say block and update the message to “I found it!”
  • From the control category, add a stop all block to end the game
detect a collision with the goal
penguin code for collision detection

Hint: You don’t have the complete the maze to test your game. Just drag your character sprite to the end in your game preview.

Your maze game is complete! Play the maze game.

Click the green flag and give it a try. If you want to share it with other people and let them remix it, click the “Share” button at the top. 

completed maze game gif

You can “see inside” the completed maze game to view the full Scratch code. 

Challenge yourself by adding the bonus features to your maze. 

Bonus: Animate the player 

We can animate the penguin by making it look left and right when it moves. To do this, we’ll create a costume for each look.

1. Create the costumes

  • Click on the costumes tab, you will see different poses for the penguin on the left
costumes tab in scratch
  • Rename the first costume, penguin2-a to look front 
  • Rename the last costume, penguin2-d to look right
choose the look front penguin costume
  • To create a penguin looking left, right click and duplicate the look right costume
duplication the look right costume
  • Highlight the new costume in the paint canvas and click flip horizontal. You should now have a penguin looking left.
  • Rename this new sprite to look left
flip the costume horizontal

The final costumes will look like this:

rename the costume look left

Your penguin now has different costumes to show which direction he’s facing.

2. Change the costume with arrow keys

Go back to the Code tab to add code to the penguin sprite. Under each key press, we will switch the costume to match the direction the penguin is facing.

  • Under the when right key pressed, add a switch costume to look right
  • Under the when left key pressed, add a switch costume to look left
  • Under the when up key pressed, add a switch costume to look front
  • Under the when down key pressed, add a switch costume to look front
switch costumes block added to arro key blocks

Try pressing the arrow keys and see if your penguin is facing the right direction.

3. Set the costume when the game starts

But, when we press the green flag the penguin isn’t always facing forward.

  • Under the when green flag clicked block, add a switch costume to look front
switch costume to look front
completed code to switch costumes

Start the game over by pressing the green flag. Your penguin should start looking forward, then look right or left depending on which direction it’s moving. 

Now your penguin is animated to look like it’s walking.

Bonus: Add a timer 

We can add a timer to make the maze more challenging. Let’s give the player 60 seconds to complete the maze game before the penguin disappears.

1. Create a Time variable

A variable is used to hold information that changes. Our time decreases every one second, so we can use a variable to save that value.

  • Go to variable category, right-click my variable and rename it to Time
  • Check off the box next to the Time variable

You should see the Time variable in your game preview now.

2. Start the Timer 

If we want the player to have 60 seconds to play, we should set the timer to start at 60. 

  • Add a When green flag clicked block
  • From the variable category, drag a set Time to 60
set time to 60

Press the green flag to see the time reset.

3. Count down the timer

Use a loop to count down the timer every 1 second. 

  • Add a Repeat until loop under the set Time block
  • In the operators category, add a less than block in the repeat until loop. Repeat until Time < 1.
  • Add a wait 1 second block inside the loop
  • Then decrease the time variable using change Time by -1
loop to count down the timer
showing timer in game preview

Press the green flag to see the time counting down.

4. Show and hide the penguin

The penguin should show when the game starts, but hide after the time runs out. 

  • After the When green flag clicked block, add a show block
  • After the Repeat until loop, add a hide block
add show and hide blocks
show and hide penguin

That’s it! Press the green flag to test your timer one more time. It should be counting down the time and hiding the penguin once the time runs out.

Give yourself a pat on the back. You completed the maze game tutorial. See the complete game with bonuses and remix it

More Scratch Tutorials for Kids

Try making another Scratch game using a fun step-by-step tutorial:

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Code more games in Scratch!

Continue coding games in Scratch with the guidance of a live, expert instructor. We teach kids how to code and practice analytical thinking, computational thinking, problem-solving, and logical reasoning.

Kids, ages 8-10, who want to learn more about Scratch coding can join the Elementary School Core Track. We offer a structured Scratch curriculum with project-based learning for hands-on practice. Enroll today to get started.

Learn to make games in Scratch in our top-rated coding classes for kids.

The post How to Make a Maze in Scratch in 7 steps appeared first on CodeWizardsHQ.

]]>
How to Make a Game on Scratch with Levels https://www.codewizardshq.com/how-to-make-a-game-on-scratch-with-levels/ Tue, 16 Jul 2024 02:16:31 +0000 https://www.codewizardshq.com/?p=63882 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

When kids develop their own games in Scratch, they can add different levels to make their game more fun and engaging. In this tutorial, I’ll show you how to create a game with levels in Scratch based on points. Leveling up in a game is one of the most satisfying feelings for any player. It’s […]

The post How to Make a Game on Scratch with Levels appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

When kids develop their own games in Scratch, they can add different levels to make their game more fun and engaging. In this tutorial, I’ll show you how to create a game with levels in Scratch based on points.

Leveling up in a game is one of the most satisfying feelings for any player. It’s a sense of achievement and accomplishment that makes playing games so addictive!

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

Popular games like Super Mario, Legend of Zelda, or Final Fantasy all use levels to challenge players and present new skills, worlds, and opponents.

Kids can also learn Scratch coding in our top-rated coding classes for kids. They’ll code games with a live instructor and build projects in every class.

What is a game level in Scratch? 

A game level is part of a game that players must complete before advancing. Many games have progressive levels where players must complete every level to finish the game. 

Anything can happen in a new level! 

A new level can signal changes like increased difficulty, new challenges, location, characters, or gameplay. Levels can be represented in maps, stages, missions, courses, or rounds.

Leveling up in a game can depend on different factors too. Players may level up based on points, experience, goals, etc.

Some games use level as a ranking method. Players or characters have individual levels, like Pokemon cards and Minecraft. As the player gains experience, they level up, acquiring new abilities and access to new content.

Why add levels to your Scratch game?

Levels are a common feature in all types of computer, mobile, and online games. Some games even have hundreds or unlimited levels for players to conquer.

Game levels motivate players to keep playing. Adding levels to a game is a way to challenge players, give them a goal to work towards, and explain how to progress in the game. 

For game developers, adding levels helps control the gameplay and design. Levels can also carry forward the story or narrative of the game, immersing the players in the storyline. 

How do you add levels to a Scratch game?

There are many different ways to add levels in Scratch. You first need to decide on the game logic.  

How will players advance levels? 

Decide which factors will allow players to advance, such as time, points, actions, etc. In the Dragon Jam game, players advance by collecting a specific amount of strawberries.

What happens when a player advances levels? 

Decide what features will change at each level. This can include the location, characters, goals, etc. In our tutorial game, a new level signals a change in the location and the goal to reach the next level.

Once you’ve decided on the game logic for your levels, you can write the code to execute it.

Steps to Make a Game on Scratch with Levels

Complete this Scratch tutorial for kids to build a game with levels.

Scratch dragon game with levels

Play and remix the Dragon Jam game now.

What you need:

Scratch account: Create a free Scratch account

No coding experience is necessary for this Scratch tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

Step 1: Create a new Scratch project

Get started by creating a new project in Scratch. 

create a new scratch project

A new project will open up and you will see the Scratch interface.

scratch project interface

Now, we can code your game! 

Hint: You can also remix this project and others to see the code.

Step 2 Add Sprites

We need a player (dragon) sprite and a loot (strawberries) sprite for our game.

  • Delete the cat sprite first. Click on the cat sprite and the trash can icon.
add sprites
  • Click on the “Choose a Sprite” button and select “dragon”. Resize it to 30.
  • Click on the “Choose a Sprite” button and select “jar”. Resize it to 30.
add sprites
resize sprites

Your player and your loot are all set! Next, add a backdrop.

Hint: Choose or paint your own sprites to create a different theme for your project. 

Step 3 Add a backdrop

Let’s start by adding one backdrop, when we switch levels we can add additional backdrops to each level.

  • Click the “Choose a Backdrop” icon and add the “Castle2” backdrop
add backdrop
choose a backdrop

You should now see your game background in the preview.

Add backdrops gif

Hint: Choose or paint your own backdrop to match the theme of your project. 

Step 4 Move the Dragon

Your player, the dragon, needs to move from side to side to catch the strawberries. 

Let’s add code to move the dragon right and left using arrow keys. We will use the “Events” blocks.

  • Click on the dragon sprite to add code to it
  • Add the “When space key pressed” block and change the dropdown to “right arrow”
  • Underneath that, add a “Change x by” block and use 15 to move right
  • Add the “When space key pressed” block again and change the dropdown to “left arrow”
  • Underneath that, add a “Change x by” block and use -15 to move left
arrow keys
move the dragon gif

Test it out, your dragon should move when you press the arrow keys! 

Hint: Change the 15 and -15 values to move your player faster or slower. 

Step 5 Make Falling Strawberries

Now, let’s make it rain strawberries. We need a lot of strawberries, so we will be making clones of the one strawberry sprite.

  • Click on the strawberry sprite to add code to it
  • Add a “When green flag clicked” block that will start our code
  • Add “Hide” block to hide the original sprite
  • Add a “Forever” loop 
  • Inside the loop, use the control blocks to “Wait 1 second” and “Create a clone of myself”
forever loop
make falling strawberries gif

Each new clone will fall towards the dragon from a random position at the top of the game screen.

  • Since the x position of the sprite changes every time, first make a new variable called x position to store it.
  • Uncheck the variable so it doesn’t show in your game screen.
update sprite positions
  • Add a “When I start as a clone” block
  • Add “Show” block so we can see the clone 
  • Go to x and y block, use the x position variable and 150 for the position
  • Use a “Glide” block to bring the strawberry down to a y position of -150
  • Delete the clone once it is off the screen
scratch blocks for glide
variables gif
variables gif

Click the green flag to watch your strawberries falling from the sky.

Hint: Change the number of seconds in Glide to make your strawberries fall faster or slower.

Step 6 Add Score

Our player levels up based on the score, so we need to calculate a score in our code.

  • The score changes, so make a new variable called “score” to store it.
  • When a new game starts the score should be 0. Under “When green flag is clicked” add a “Set score to 0” block. 
add score in scratch

Next, increase the score every time the sprites touch. 

  • Add “When I start as a clone” block
  • Then, add a “Wait until” block and use the sensing block for “touching”. Change the dropdown to “Dragon” or your player sprite. 
  • Add a “Change by” block from variables to change the score variable by 1.
  • Finally, add a “Delete this clone” block to make the strawberry disappear
scratch blocks for touching
Add score gif

Move your dragon around to collect the strawberries and watch as the score increases!

Hint: Try adding different loot with higher or lower scores to make the game more interesting.

Step 7 Add Levels

Now, let’s make the game more challenging by adding levels. In each level, the player needs to collect more strawberries (or more points) to advance. So, think about the game logic.

How many strawberries does the player need to advance in each level? 

Level 1 Score 3 points to advance (total of 3 points)

Level 2 Score 5 points to advance (total of 8 points)

Level 3 Score 7 points to advance (total of 15 points)

Level 4 Score 10 points to advance (total of 25 points)

Level 5 Win!

What happens after the player advances a level? The backdrop will change. 

You’ve already added the backdrop for level 1. We will add 4 more backdrops for the other levels.

  • Click the “Choose a Backdrop” icon and add another backdrop. 
  • Repeat this 4 times with a different image each time. We are using the Savanna, Underwater 1, Mountain, and Metro backdrops

  • You can see all of the backdrops you chose in the “Backdrops” tab. If you have a default white background, click the trash can icon to delete it.
Add backgrounds for scratch levels
Add backgrounds for scratch levels gif

The location, or background, changes when players pass a level. We can write that in code like this:

  • First, click on the Dragon sprite to add code to it
  • The level changes, so make a new variable called “level” to store it.
  • Add a “When green flag is clicked” and a “Set level to 1” block. When a new game starts the level will begin at 1. 
  • Use “Switch backdrop to” and choose the backdrop you want for the first level.
  • Add a “forever” loop
  • Inside the loop, we will add an if statement for each change in level. For example, if the score is greater than 2, set the level to 2 and switch the backdrop to Savanna.
  • Copy the If statement and add the change in score, level, and backdrop for each level you have.

Press the green flag to play! You should see the levels increasing and the backdrop changing.

Hint: Customize your levels by changing the scores or backgrounds. 

Step 8 Win Logic

Players can collect strawberries and level up, but they don’t know when they win or lose. Let’s display a message to the player when they win.

On the Dragon sprite, we will add code inside the level 5 if statement.

  • Add a “Broadcast” block and change the message to “you win”
  • Add a “Stop all” block to end the game

Create a message to the player that they win.

  • Click on the cat icon, select “Paint” 
  • Select the rectangle option to draw a white rectangle
  • Then, select the text option and type “You Win” in red on top of the rectangle
  • Right-click on the sprite to name it “You Win”

We only want to show the “you win” sprite when the message is received.

  • On the “you win” sprite, add a “When Green flag is clicked” block and a “hide” block
  • Add a “When a receive” block and change the message to “you win”
  • Add a “show” block and “stop all” to end the game.

You should now see the win message when you reach a score of 25!

Hint: Test your win message by setting the score to start at 24 instead of 1. 

Step 9 Lose Logic

Now, display a message to the player when they lose.

On the strawberry, send a losing message when a strawberry reaches the floor.

  • Under the “glide” block, add a “forever” loop
  • Inside the loop, add an “If” statement with an operator for y position is less than -149.
  • Add “broadcast” and create a new message called “game over”
  • After the loop, add “delete this clone” block.

Create a message to the player that they lost,

  • Right-click on the “You Win” sprite and duplicate
  • Go to the Costumes tab and edit the text to “Game Over”
  • Right-click on the sprite to rename it “game over”

We only want to show the “game over” sprite when the message is received. Since you duplicated a sprite, the same code will also be on this sprite.

  • Update the “when I receive” block and change the message to “game over”

All of your game logic is complete! Play the Dragon Jam game.

Click the green flag to play your game. If you want to let other people see your project and remix it, click the “Share” button at the top. 

You can “see inside” our completed Dragon Jam to get a peek at the full Scratch code.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

More Scratch Tutorials for Kids

Try making another game with levels. Pick one of these fun Scratch game tutorials and add levels.

Learn How to Make Games with Levels in Scratch

Coding games in Scratch is a great way for kids to learn about programming fundamentals and game development. 

If your child wants to dive deeper into Scratch, join our top-rated Scratch classes for kids. Students in our elementary school coding program learn to code with Scratch and advance to other languages like HTML/CSS, JavaScript, and Python. Learn from live, expert instructors while building fun projects and games that your child personalize and share.

Enroll today to start coding in Scratch!

The post How to Make a Game on Scratch with Levels appeared first on CodeWizardsHQ.

]]>
How to Make a Jumping Game on Scratch https://www.codewizardshq.com/how-to-make-a-jumping-game-on-scratch/ Wed, 28 Feb 2024 07:45:23 +0000 https://www.codewizardshq.com/?p=60835 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Hey there, young explorers! Ready to learn how to make a jumping game on Scratch? We’re building a Rocket Jump game where you’ll zoom through space going from platform to platform. Before we start building our game, let’s talk about Scratch. Scratch is a super cool place where you can make your own stories, games, […]

The post How to Make a Jumping Game on Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Hey there, young explorers! Ready to learn how to make a jumping game on Scratch? We’re building a Rocket Jump game where you’ll zoom through space going from platform to platform. Before we start building our game, let’s talk about Scratch. Scratch is a super cool place where you can make your own stories, games, and animations — like a digital LEGO set that’s all about your ideas!

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

It’s like learning to speak the language of computers! And the best part? You don’t have to type any words or numbers. Instead, you snap together colorful blocks that look a bit like puzzle pieces. Each block is a command that tells your characters and objects what to do.

In our elementary school curriculum, students start their coding journey with Scratch. As kids build games and animations with Scratch, they’re laying the groundwork for computational thinking—a vital skill set for coding with actual code. 

Let’s start our coding journey together!

Complete this tutorial to create a jumping game on Scratch.

Play and remix the Rocket Jump game now.

What you need:

No coding experience is necessary for the Rocket Jump tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

Steps to make a jumping game in Scratch:

  • Step 1: Setup the scratch project
  • Step 2: Make the rocket move with keyboard keys
  • Step 3: Add “gravity” to make the rocket fall.
  • Step 4: Add the platform
  • Step 5: Make the rocket jump when touching the platform.
  • Step 6: Change platform position everytime rocket touches it.
  • Step 7: Add scores in the game.
  • Bonus 1: Change costumes of the Rocketship sprite
  • Bonus 2: Increase difficulty as the game progresses

In this game, players guide a rocketship through the starry cosmos using the arrow keys to navigate left and right. The rocket automatically falls due to gravity, but upon touching the platform, it jumps upwards to earn points. Each successful landing on the platform boosts the rocket higher and changes the platform’s position, making each jump a new challenge. The aim is to keep the rocket aloft as long as possible while racking up jumps for a high score.

Step 1: Setup the Scratch project

Create a New Scratch Project

  • Open Scratch, and you’ll see a button that says “Create”. Click it, and you’re on your way!
  • At the top, you’ll find the name “Untitled”. Click on it and type in “Rocket Jump” to name your game.


Set the Stage

  • Every game needs a background. Look at the bottom-right corner for a little picture that looks like mountains. That’s the backdrop. Click it!
  • Choose a backdrop with stars to make it look like outer space. You can pick one or even draw your own.
choose a game background
  • Next, click on the picture of the cat to select a sprite. You can pick a rocket from the ones they have. 
choose a scratch sprite
  • Set its size as per your need. For rocket sprite, a size of 40 works the best.
resize the rocket in the jumping game

After we have both backdrop and sprite setup, you should have something like below in the game preview area:

Step 1 results, rocketship sprite with background

Step 2: Make the rocket move with keyboard keys

Moving Right

  • Let’s get our rocket moving. Click on the Events category, and you’ll find a block that says “when space key pressed”. Drag it out.
  • We want to move right when we press the right arrow, so click on the little dropdown arrow on that block and choose the “right arrow”.
  • Now, click on the Motion category (it’s the blue one), and find “change x by 10”. Drag that and snap it right under the “when the right arrow key pressed”.
move the rock et right and left

Moving Left

  • Our rocket should move left too! Let’s duplicate the blocks you just made. Right-click on them and choose “duplicate”.
Duplicate blocks to move
  • Change “right arrow” to “left arrow” and “10” to “-10”. Now, when you press the left arrow, your rocket will move left!
Add arrow key to move

Step 3: Add “gravity” to make the rocket fall.

Setting the Fall

  • In space, things float down slowly. We’ll make our rocket do that. Find the Events category again and use the “when green flag clicked” block.
  • We need to tell the rocket where to start. Go to Motion, find “go to x: y:” and fill in “x: -144” and “y: 123”.
  • To make it keep falling, go to Control (the orange category), find “forever,” and drag it under your “go to” block.
  • Inside “forever,” go back to Motion and find “change y by”. Put “-4” in it to make our rocket fall.
Add gravity to make the rocket fall

Step 4: Add the Platform

Creating the Platform

  • Our rocket needs a platform to jump from. Click the paintbrush to make a new sprite.
  • The click the square icon and draw a rectangle at the center of the screen. This is your platform. It can be any color you like!
Create a platform for your jumping game

Positioning the Platform

  • Let’s put the platform in place. Under Events, use “when green flag clicked” again.
  • In Motion, find “go to x: y:” and fill in “x: -154” and “y: -55”. That’s where the platform will wait for our rocket.
position the platform for the rocket to jump on

Step 5: Make the rocket jump when touching the platform.

The rocket jumps!

  • We want our rocket to bounce when it touches the platform. Inside the rocket’s “forever” loop, add the “if then else” block from the Control category. 
  • From the Sensing category (it’s the light blue one), grab “touching” and select the “Sprite1” (your platform sprite) from the dropdown.
  • In the “else” part, move the “change y by -4” block you made before.
  • For the “if” part, first, we make the rocket jump. Grab “repeat” from Control and type “15” in it.
  • Inside “repeat,” add “change y by 4” from “Motion” and “wait 0.05 seconds” from Control after it. This makes the rocket go up for a bit, like it’s bouncing!
make the rocket jump when touching platform
make the rocket jump when touching platform

Step 6: Change the platform position every time the rocket touches it.

Moving the Platform

In the rocketship sprite

  • We’ll make the platform move every time the rocket jumps. In the rocket’s code, in the “if” part, find Events and use “broadcast message1”.
change the platform position in scratch

In the platform sprite

  • Wait for that broadcast message. Use “when I receive message1” from Events
  • To change the spot, use “glide 1 secs to x: y:” from Motion.
    • Set the value of y with y position block from the Motion category. This will make sure the platform remains at the same height.
    • For x, add a random block from Operators category, and set the lower limit to -200 and upper limit to 200
broadcast message to glide

This completes our game logic, we can now move our rocket to go left and right, and use the platform to stay afloat.

rocketship jumping, game logic complete

Step 7: Add scores in the game.

Keeping track of scores

A game is no fun without the scores. To set up scores, create a new variable named Scores.

  • Click on the Variables category and choose “Make a Variable”
  • Name it Scores, press ok, and you should see it appear in your variables list. Make sure it’s checked off so it shows in your game.
make a scores variable

In your rocketship sprite, 

  • Drag the set the value of Scores variable and position it below the “When flag clicked”. Set its value to 0.
  • Inside the if condition, in the “forever” block, add the change value by 1 block. And select the Scores variable from the dropdown.
set the score in the jumping game

Your game is complete!

Bonus 1: Change costumes of the Rocketship sprite 

Change costume when jumping

To add the rotate effect in the rocket, we can change its costume when it goes up.

In the Rocketship sprite

  • Drag the “next costume” block from the looks category, and place it inside the repeat 15 block, in the if condition.
  • To reset the costume, drag the “switch costume to” block from the Looks category, and place it below the “when green flag clicked” block.
  • Select the default costume value. For the rocketship sprite, the costume rocketship-e makes perfect sense, as it doesn’t have any ignition.
change costumes
completed jumping game in scratch

Bonus 2: Increase difficulty as the game progresses

Draw more costumes in platform sprite

To increase the difficulty of the game, add costumes to the platform sprite with a smaller size of platform.

  • Select the platform sprite, and go to the Costumes tab.
  • Right click on the Costume, and select duplicate.
  • Decrease the size of the platform in the duplicated sprite.

In the Code tab of the platform sprite,

  • Add the “if then” block from the Control category and place it below “when I receive message1” block.
  • For the condition of the “if” block, use the > block from the Operators category.
  • Inside > block, add scores variable on left side, and any value of scores when you want to change platform on right side. For example, we can use 15.
  • Inside the “if” block, add the “Switch Costume” block from the Looks category, and select the costume with decreased size.
  • Add another switch costume block and place it below the “when green flag clicked” block. 

Let’s play!

It’s time to test your game by pressing the green flag above your game’s screen. 

Compete with your friends and see who can score the most scores.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Make More Games in Scratch

CodeWizardsHQ firmly believes that initiating the exploration of technology and programming during childhood can pave the way for future success. We have designed a structured program for elementary school coding, that leverages the power of Scratch to teach coding principles.

In the first course, Animation and Games with Scratch, students delve into essential programming concepts, including variables, loops, and conditionals. By the end of this course, they will possess the ability to create their own games and animations using Scratch. This prepares them for their journey toward a future in the ever-evolving world of technology.

Our coding classes for kids allow children to nurture their skills, unleash their imaginations, and experience the joy of learning!

The post How to Make a Jumping Game on Scratch appeared first on CodeWizardsHQ.

]]>
5 Popular Game Mechanics in Scratch [60 Second Lessons] https://www.codewizardshq.com/5-popular-game-mechanics-in-scratch/ Sat, 13 Jan 2024 01:30:13 +0000 https://www.codewizardshq.com/?p=58749 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Moving, jumping, and scoring are standard features in almost every game we play. Kids can learn how to add these popular game mechanics to their Scratch games in just a few clicks. In our elementary school coding classes, kids use Scratch to code their own games that they can play and share with friends. When […]

The post 5 Popular Game Mechanics in Scratch [60 Second Lessons] appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Moving, jumping, and scoring are standard features in almost every game we play. Kids can learn how to add these popular game mechanics to their Scratch games in just a few clicks.

In our elementary school coding classes, kids use Scratch to code their own games that they can play and share with friends. When they are beginners, they’re often asking how to include these simple game mechanics and it’s easier than they think.

Here are five popular game mechanics that take just 60 seconds to add to any game in Scratch.

  1. Move left and right
  2. Add gravity
  3. Jump
  4. Follow the Mouse
  5. Keep Score

Kids Can Quickly Code Games in Scratch

Scratch is a free block coding language and online community that allows kids to create programs and games using drag-and-drop. 

Scratch is an excellent choice for kids who want to build games fast. There’s no setup and the drag-and-drop coding interface is easy enough for any beginner. In Scratch, kids can really focus on understanding coding concepts rather than learning syntax.

We teach these fundamental concepts through engaging projects in our Scratch classes. Elementary school students learn to code games and apps using Scratch first. This helps them build a solid understanding of fundamental coding concepts before they move on to text-based coding.

What are game mechanics? 

Basic game mechanics refers to the fundamental rules, interactions, and systems that govern how a game operates.

These make up the core framework of a game, shaping the player’s experience and defining the rules of engagement within the game world. 

When you start a new game, you learn the basic mechanics first in order to play. 

Game developers use basic game mechanics to create engaging and enjoyable gameplay, providing structure, and a sense of progression for players. A few examples include:

Player Controls: Player controls define how users interact with the game. This includes keyboard and mouse inputs, gamepad controls, touch gestures, or any other input method.

Developers design controls to be intuitive and responsive, allowing players to navigate the game world, perform actions, and interact with objects.

Objectives and Goals: Games typically have specific objectives or goals that players must achieve to progress. These objectives can include completing missions, solving puzzles, defeating enemies, or reaching a specific destination. Well-designed objectives create a sense of purpose and motivation for players.

Scoring and Rewards: Scoring systems track players’ performance and provide a quantifiable measure of success. Rewards, such as points, items, or in-game currency, are often tied to achievements and milestones. Scoring and rewards incentivize players to strive for improvement and mastery.

Physics and Collision Detection: Physics engines simulate realistic movement and interactions within the game world. This includes gravity, friction, and object collisions. Collision detection ensures that objects interact believably, contributing to a more immersive and coherent game experience.

You can see some of these at work in the 25 best Scratch games.

5 Popular Game Mechanics in Scratch

Watch the 60-second Scratch video lessons to add these features to your next game! 

1. Move Left and Right 

Moving left and right is a fundamental part of many games, particularly in 2D platformers and side-scrolling games. This basic movement mechanic may seem simple, but it plays a crucial role in the gameplay experience. It can also influence player control, level design, pacing, and even contribute to the narrative impact of the game. 

In the Rocket Landing game, the rocketship moves left and right.

If we want our rocket to move left and right, we need to change the X value.

  • In your code, select the When Key Pressed block then choose right arrow. 
  • Use a motion block to Change X by 5.
  • Use the When Key Pressed block again then choose left arrow. 
  • Then use the motion block to Change X by -5.
  • Now, press the green flag and use the arrow keys to test your movement. 

Add this to your Scratch code:

Scratch code for right and left

2. Add Gravity

Incorporating gravity into a game world will add realism and can be an added layer of challenge. Games that involve falling or flying heavily depend on gravity. Changing gravity can lead to shifting landscapes, floating platforms, or other dynamic elements that keep the gameplay experience fresh and unpredictable.

In our Rocket Landing game, the rocketship falls from the sky.

If we want our rocket to move from top to bottom, we need to change the Y value.

  • In your code, drag a When Green Flag clicked block in events.
  • Select the Repeat loop and loop 200 times.
  • Use a motion block to change Y by -2. Put that inside the loop, so the rocket goes down by -2 , 200 times. 
  • After it falls, set it back to the top with the Go To block x = 0 and y = 130 
  • Now, press the green flag to test your rocket. It’s falling!

Add this to your Scratch code:

Scratch code for gravity

3. Jump

Jumping is another fundamental game mechanic that you’ll see in virtually every game. Players can jump to navigate vertically, overcome obstacles, or reaching higher platforms. The ability to jump make a game more dynamic because they can introduce features like moving platforms or changing landscapes that require players to adapt their jumping skills in real-time.

In the Frog Jumper game, the frog jumps over a snake when you click the spacebar.

To move the frog up and then down, we need to change the Y position in Scratch.

  • In your code, select a When Space Key Pressed block in events.
  • Use a motion block to Change Y by 15. 
  • Select the repeat loop and repeat the change in Y 15 times. Add this around the motion block.
  • Right-click to duplicate your loop and change Y to -15. This moves the frog down.
  • Now, press the green flag to test your frog. It jumps!

Add this to your Scratch code:

Scratch code for jumping

4. Follow the Mouse

The “Follow the Mouse” game mechanic, also known as mouse tracking or mouse-based control is important in certain types of computer games. It is crucial in certain genres like point-and-click adventures or real-time strategy games. Players may move the cursor with the mouse to explore the environment, interact with objects, or solve puzzles.

In the Candy Collector game, the ghost follows the mouse. Anytime the mouse moves our ghost will move.

  • Add a When Green Flag clicked block.
  • Choose the motion block for Go To and select mouse-pointer.
  • We want the ghost to follow the mouse pointer forever, so use a forever loop. 
  • Put it around the Go To block to repeat that action.
  • Click the green flag and move your mouse. Does your sprite follow your mouse?

Add this to your Scratch code:

Scratch code for follow the mouse

5. Keep Score 

Keeping score is a fundamental game mechanic that serves various purposes across different types of games. Whether it’s a simple arcade game or a complex strategy game, the scoring system adds a competitive element to games, motivating players to improve their skills and achieve higher scores. It also provides clear goals for players to achieve and gives immediate feedback on player performance. 

In the Monkey Tickler game, the score goes up when you click on the monkey.

  • The score changes, so first go to variables and Make a Variable called score.
  • In your code, drag a When Green Flag clicked block in events.
  • Set the score variable to 0 when you start your game.
  • Then, get the event block When This Sprite is Clicked.
  • Every time we click the sprite, the score will change by 1. 
  • In variables, get Change Score by 1.
  • Now, press the green flag to test your game.
  • The score increases when you click your sprite.

Add this to your Scratch code:

scratch code for scoring

Take your Scratch skills to the next level.

Now that you have your basic game features, take your Scratch skills to the next level! The elementary school core track, for kids ages 8-11, is a structured and fun way to advance your child’s coding skills. Kids will build a foundation in coding and practice skills like logical reasoning, problem-solving, and critical thinking. 

Encourage your child to learn Scratch and empower the next generation of creators. See Scratch classes and enroll.

The post 5 Popular Game Mechanics in Scratch [60 Second Lessons] appeared first on CodeWizardsHQ.

]]>
How to Make a Platformer on Scratch https://www.codewizardshq.com/how-to-make-a-platformer-on-scratch/ Mon, 25 Sep 2023 02:23:30 +0000 https://www.codewizardshq.com/?p=57710 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

In this tutorial, I’m going to show you how to make a platformer game in Scratch. Scratch is a simple drag-and-drop coding language for children to learn basic programming skills. Kids can build all kinds of games and apps in Scratch. With the Scratch classes I’ve taught, kids always enjoy the exceptional interactivity and enjoyment […]

The post How to Make a Platformer on Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

In this tutorial, I’m going to show you how to make a platformer game in Scratch. Scratch is a simple drag-and-drop coding language for children to learn basic programming skills. Kids can build all kinds of games and apps in Scratch.

With the Scratch classes I’ve taught, kids always enjoy the exceptional interactivity and enjoyment Scratch offers. In our Elementary School Core Track, students can craft their own interactive games while learning fundamental programming concepts like variables, loops, and more.

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

Try this tutorial to learn about accepting user input, adding player controls, checking for collisions between two sprites, and more. Let’s get started!

Play and remix the Chick’s Adventure game now.


What you need:

  1. Scratch account: Create a free Scratch account

No coding experience is necessary for this Scratch tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

How to Make a Platformer on Scratch

  1. Set up the Project
  2. Set the Scene
  3. Add Gravity to the sprite
  4. Add platforms for the sprite to jump on
  5. Add the user controls
  6. Change the levels
  7. Bonus: Make a way to win or lose

Step 1: Set up the Project

In this section, you will create a new Scratch project, give it a name, and save it so you can get started on your platformer game!

1. Login to Scratch

2. Create a New Scratch Project

  • Once you are logged in, click the Create button at the top of the page.

3. Name the project and delete the Scratch cat

  • In the top textbox on the Scratch editor, name your project whatever you would like!
  • Then, delete the Scratch cat by clicking the trash can next to the sprite in the spite area.

4. Save the project

  • Click File, then Save now. You’re now ready to make your platformer game!

Step 2: Set the Scene

For this section, you will add the backdrop and a sprite for the player to control, which will set the scene for your platformer game! 

1. Add a backdrop to your game!

  • Click on the Add a backdrop button on the bottom right-hand side of your editor.

  • Choose whatever backdrop you’d like! I chose Blue Sky 2 for my project. When you’re ready, click your chosen backdrop.

Great, now your backdrop should show up!

2. Select a Player Sprite

  • On the bottom right-hand side of your page, click on the Choose a Backdrop button.
  • Click any sprite you would like. In this tutorial, I decided to select the Chick sprite.
  • You can change the size of the sprite if you’d like as well. Edit the Size textbox in the sprite area to do this!

Awesome job, you should now have a sprite on your screen that is sized how you want. Click and drag the sprite around to move it to a new spot!

Step 3: Add Gravity to the Sprite

In this section, you will learn how to use multiple motion blocks to change the player’s position and move them downwards on a loop, which will simulate gravity.

1. Detect when the game is being played

  • In the Code block tab, click on the Events category.
  • Then, select the When Green Flag clicked block and drag it into your code area.

2. Make the sprite move downwards on a loop

  • Go to the Control category and drag a forever block into the code area and attach it under the When green flag clicked block.


  • Then, go to the Motion category and click and drag a change y by block. In the textbox, you can change the number if you’d like. The higher the number, the faster they fall.


  • Change the number in the change y by textbox to a negative number to make it go downwards.


3. Set the sprite’s initial position

  • In the Motion category, click and drag a go to x and y block and connect it under the when green flag clicked block, but above the forever block.

  • Press the Green Flag above the game area. Does your sprite fall? Every time you press the Green Flag, your sprite should start from the beginning and fall down!

Step 4: Add platforms for the sprite to jump on

In this section, you will add platforms for the player to jump on to avoid falling. Once the player touches a platform, you will make it so gravity turns off until they aren’t touching the platform anymore!

1. Add a platform for the sprite

  • In the bottom-right corner of the Scratch editor, click Choose a Sprite.

  • Choose whatever sprite you want in the menu. For this tutorial, I chose the Clouds sprite.

  • Move the new sprite to a position under the player’s sprite and press the Green Flag button. Does it work as intended?

2. Make it so the sprite can’t go through the platform

  • Click on the Chick sprite. Make sure that it is selected before moving on to the next step.

  • Then, in the Code tab, go to the Control category and click and drag an if then block to under the change y by block.

  • Go to the Sensing category and drag a touching block into the code area. Click the block and change the dropdown selection to the sprite you recently added to the game. In my case, I selected the Clouds sprite.

  • In the Motion category, drag a change y by block to be in the if then block. Make sure that the number in the change y by block is the positive version of the one outside of the if then block. If you had a -10 in the first change y by block, you should have a 10 in the new one.

  • Press the Green Flag button. Does your player sprite stop when it touches the platform?

Recommended: How to Make a Game on Scratch

Step 5: Add the user controls

In this section, you will allow the player to move their sprite back and forth in the game, which will make it so they can eventually switch levels. You will also make it so the player can jump from platform to platform!

1. Allow the player to move left or right

  • In the Control category, drag two if then blocks to inside the forever block.


  • Then, go to the Sensing category and drag two key pressed blocks into the if then blocks you added. Change one of them to left arrow and the other to right arrow in their dropdowns.


  • Go to the Motion category and drag two move steps blocks into the left and right arrow key pressed blocks. Keep them both the same number.


  • Next, in the Motion category, drag a point in direction block into both the key pressed blocks. Then, change the number in the left arrow key pressed block to -90. The right arrow one should be 90.


  • In the Motion category again, drag a set rotation style block to under the Green Flag clicked block.



Great work so far! Does your sprite move back and forth with the left and right arrow keys?

2. Make the player jump

  • Go to the Events category and drag a when key pressed block into the code area. Change the dropdown in that block to up arrow or spacebar.


  • Then, in the Control category, drag a repeat block under the when key pressed block.

  • Get a change y by block from the Control category and place it in the repeat block. Change the number in the change y by block to be about 15, or a number bigger than the gravity number.

  • To add a delay between jumps, go to the Control category and drag a wait block under the repeat block.

  • Press the Green Flag button, does the sprite jump when you press the up or spacebar key?

Step 6: Change the levels

In this section, you will create a checkpoint that the player must touch to switch to the next level. You will be able to use your creativity to develop multiple levels using this method.

1. Add a checkpoint

  • Choose another sprite to serve as a checkpoint the player has to get to in order to get to the next level. For my project, I chose a Sun sprite. Feel free to change the size of the sprite as well.


2. Change levels when the checkpoint is touched

  • Go to your Code tab and select My Blocks. Then, click the Make a Block button.


  • There will be a popup. In that window, change the name in the textbox to Next Level. Then, click the Ok button.


  • You will notice a define block in your code area now. This is called a function, and basically is a small segment of code that performs an action. We will use it to change levels!



  • Then, attach a go to x and y block to the define block. Make sure the x and y values are similar to the ones you originally created in the when green flag clicked block.


  • Next, in the Events category, click and drag a broadcast block in to the define block as well. In the text portion, change it to something like Next Level.


  • Click on the checkpoint image in the sprites list area on the right of the page to make sure you’re changing the correct sprite. Then, in the Events category, move a when I receive block to the code area. It should say When I receive Next Level.


  • Then, from the Looks category, drag a next costume block under the when I receive block.


  • Then, click on the Costumes tab for your platform. You can click the Zoom out button – shaped like a magnifying glass with a minus on it, which is situated in the bottom right corner of the picture editor. This allows you to edit more of the image all at once.


  • Create another platform for the player to jump on by clicking and dragging to select the whole drawing. Then, click the Copy and the Paste buttons, and drag the new one to a better position.


  • You should now have two platforms to jump on!


  • Next, get an if then block from the Control category and drag it under the if right arrow pressed block.


  • Then, find a touching block from the Sensing category and put it in that newly added if then block.



  • Go back to the My Blocks category and click and drag the Next Level block into that if then block.



  • Click on the Platform sprite again. From the Events category, add a when green flag clicked. Then, go to the Looks category and put a switch costume to block to reset the platforms whenever the game is started.



Nice job! Do the platforms switch? From here, you can adjust each costume to make new levels.



Bonus Step: Make a way to win or lose

In this bonus section, you will make a way for the player to win by reaching a certain level, or lose by falling from the platforms! You will also create win and lose game screens for when this happens.

1. Create the win and lose backdrops

  • First, click on the Backdrops section on the bottom right of the editor in the Stage menu.


  • Once you do that, click on the Backdrops tab. Then, right-click on the backdrop you’re using in this project. Click duplicate to make an exact copy.


  • When you’re in the new backdrop, click on the Text button in the menu. Edit the text to say something like You Win!


  • Next, right-click and duplicate that new backdrop with the text as well.


  • Click the text and edit it to say something like You lose. Now you should have both the win and lose backdrops in your game!


2. Make the player lose if they fall off the platform

  • First, click on the player’s sprite. Then, go to the Looks category and get a switch backdrop to block and drag it under the when green flag clicked block. Make sure to set the backdrop to the first backdrop – not the win or lose ones. This is so that it resets whenever the player starts the game again.


  • Then, select Paint a new sprite.


  • In the Costumes tab of the new sprite, make a rectangle that is positioned at the bottom of the game screen. We’ll make it so that when the player touches this, they lose.


  • Then, go to the Code tab again and drag an if then block in the main forever block loop.


  • Next, go to the Sensing category and get a touching block and move it into the condition of the if then block you just added. Change the dropdown selection to the new sprite you created.


  • Now, go to the Looks category, get a switch backdrop to block, and change the dropdown selection to the lose backdrop.


  • Finally, go to the Control category and get a stop all block. Place it under the switch backdrop to block.


Does the lose screen display when the player falls off a platform?



3. Make the player win if they beat the last level

  • Select the platform sprite. Then, go to the Control category and place an if then block under the next costume block.


  • Then, go to the Operators category and grab a contains block. Put that in the if then block.


  • Go to the Looks category and put a costume number block in the left textbox of the contains block.


  • Finally, go to the Looks category and get a switch backdrop to block and put it in the if then block. Make sure it goes to the You Win backdrop.


Test your game, can you win?

Check Out Our Other Scratch Tutorials

Keep coding with one of these fun Scratch tutorials!

  • How to Make a Flappy Bird Game – Make an interactive game where the player must make a bird flap its wings to avoid incoming obstacles!
  • Flying Space Cat – Assist Space Cat in its space exploration mission by developing an enjoyable crystal-collecting game using the Scratch programming platform.
  • Code a Rocket Landing Game – Finish this Scratch programming tutorial designed for children and create a game where you safely land a rocket.
  • Valentines Day Card Scratcher – Create a Valentine’s Day scratch-off card with a personal touch by following this easy-to-follow Scratch programming tutorial.
  • Holidays Advent Calendar – Use Scratch to program a customized Advent Calendar for the holiday season and gradually unveil presents, treats, or activities to share with your friends adn family.
  • Halloween Candy Collector Game – Follow this simple Scratch programming tutorial and create a personalized game where you collect candies on Halloween.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Try a Scratch Coding Class for Kids

At CodeWizardsHQ, we believe that learning about technology and programming during a student’s formative years can pave the way for future success. Our specialized program tailored for elementary school children utilizes Scratch as a foundational tool for imparting coding skills.

In our inaugural course, Animation and Games with Scratch, young learners delve into crucial programming concepts such as variables, loops, and conditionals. Upon completing this course, they will possess the proficiency to craft their own games and animations through Scratch, thus equipping them for more advanced coding endeavors and a promising future in the realm of technology. Our program fosters the development of children’s skills and imagination, all while ensuring an enjoyable and educational experience.

The post How to Make a Platformer on Scratch appeared first on CodeWizardsHQ.

]]>
How to Make a Sprite Jump in Scratch https://www.codewizardshq.com/how-to-make-a-sprite-jump-in-scratch/ Fri, 16 Jun 2023 09:33:35 +0000 https://www.codewizardshq.com/?p=56532 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is an excellent coding language for children to acquire programming skills. With Scratch, kids can construct games, narratives, and animations by simply dragging and dropping various blocks of code. In the Scratch classes I’ve taught, students confirm the exceptional interactivity and enjoyment Scratch offers. The Elementary School Core Track teaches kids to craft their […]

The post How to Make a Sprite Jump in Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is an excellent coding language for children to acquire programming skills. With Scratch, kids can construct games, narratives, and animations by simply dragging and dropping various blocks of code.

In the Scratch classes I’ve taught, students confirm the exceptional interactivity and enjoyment Scratch offers. The Elementary School Core Track teaches kids to craft their own interactive games while learning fundamental programming concepts like variables, loops, and more.

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

In this tutorial, I will teach you how to make a sprite jump in the Snake Jumper game. You will learn about animating sprites, accepting user input, and checking for collisions between two sprites. Let’s get started! 

Play and remix the Snake Jumper game now.

Snake jumper game in Scratch

What you need:

  1. Scratch account: Create a free Scratch account

No coding experience is necessary for this Scratch tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

How to Make a Sprite Jump in Scratch

  1. Login to Scratch
  2. Create a new Scratch project
  3. Name your new Scratch project
  4. Choose a backdrop
  5. Choose a sprite
  6. Make the sprite move up
  7. Make the sprite move down
  8. Change the sprite’s costume
  9. Reset the sprite’s position
  10. Test your game!
  11. Bonus – Add an enemy sprite to avoid

1. Login to Scratch

Login to scratch

2. Create a New Scratch Project

  • Once you are logged in, click the blue Create button at the top of the page.
create a new project in scratch

3. Name your new Scratch project

  • Give your project a name, for example, “Snake Jumper Game”. 
  • Then delete the Scratch cat by clicking the trash can icon next to the sprite.
Name your new scratch project

4. Choose a backdrop

  • Select the Choose a Backdrop option at the bottom right-hand side of your screen.
Choose a backdrop
  • When the Choose a Backdrop screen opens up, select a background for your project. In this tutorial, I chose Jungle.
Select the jungle scratch backdrop

5. Choose a sprite

  • Select the Choose a Sprite option at the bottom right-hand side of your screen.
choose a sprite
  • Select a sprite that you would like. I chose a wizard-toad for my project.
Select the wizard toad sprite
  • Click and drag the sprite to be on the left-bottom side of the game. Then, in the Size textbox, change the size to about 75.
Position the wizard toad sprite

6. Make the sprite move up

The action of jumping is simply moving a sprite up and then back down. We will be moving the sprite when the space bar is clicked. 

  • In the Events category, drag a when space key pressed block in the code area.
make the sprite move up
  • Then, go to the Control category and drag a repeat block and attach it under the when space key pressed block.
  • Change the text in the textbox from 10 to 15, which will make the repeat block execute more times.
Add a repeat button
  • Next, go to the Motion category, and attach a change y by block inside of the repeat block. Change the text in the textbox from 10 to 15 so that the sprite’s y position changes quicker.
add a change y by block

7. Make the sprite move down

The sprite went up, now it must come down automatically. That will complete the act of jumping after the space bar is clicked.

  • Right-click on the repeat block and select Duplicate. This makes an exact copy of the repeat block and everything in it.
Make the sprite move down
  • Attach the new repeat block under the old one. Then, change the value in the change y by block to -15.
Add another repeat block

8. Change the sprite’s costume

When the sprite moves, you can change how it looks so it appears as though it’s actually jumping.

  • Go to the Looks category and get a switch costume to block. Attach it directly under the when space key pressed block, but above the repeat blocks. If you’re using the wizard-toad sprite, make sure the costume is set to wizard-toad-b.
Change the sprites costume
  • Drag another switch costume to block under all of the code. If you’re using the wizard-toad sprite, change the costume to wizard-toad-a by clicking on the costume name.
Add a switch costume to

9. Reset the sprite’s position

  • Then, go to the Motion category and drag a go to x and y block under the when green flag clicked block. Make sure the x value is about -175 and the y value is around -110.
Add a go to x and y block
  • Then, go to the Motion category and drag a go to x and y block under the when green flag clicked block. Make sure the x value is about -175 and the y value is around -110.
Add a motion block

10. Test your game!

  • Test your game by pressing the green flag above your game’s screen. Does your frog jump when you press the space bar?

Bonus – Add an enemy sprite to avoid

  1. Add another sprite
  2. Make the enemy sprite move
  3. End the game if the sprites collide
  4. Test your game!

1. Add another sprite

  • In the bottom-right corner of your screen, select the Choose a Sprite option.
Choose a sprite
  • Select a sprite of your choice. In this tutorial, I chose a Snake.
Choose the snake sprite
  • When that sprite is added, drag it to the right-hand side of the screen.
  • If the sprite is facing the wrong way, click on the Direction textbox for the sprite. Select the middle option under the clock. Then, change the 90 in the Direction textbox to -90.

  • You can also change the size of the sprite in the Size textbox. I changed mine to 75.
Change the size of the sprite

2. Make the enemy sprite move

  • Click on the new sprite.
  • In the code, add a when green flag clicked block from the Events category.
Make the enemy sprite move
  • Then, in the Control category, attach a forever block to the when green flag clicked block.
Add a forever block
  • Next, go to the Motion category and drag a go to x and y block into the forever block. Make sure the x value is about 300 and the y value is -100. This is so that the snake moves from the right side of the screen to the left!
Add a go to x and y block
  • Then, from the Control category, get a wait block and attach it under the go to x and y block. Change the value of the wait block to about 0.5.
Wait block in scratch
  • From the Motion category, drag a glide block to an x value of 300 and a y of -100.
Add a glide block

3. End the game if the sprites collide

The goal is for the frog to jump over the snake and not touch it. If the two collide, the game is over.

  • In the Events category, drag a when green flag clicked block into the code area.
When green flag clicked
  • Then, get a forever block from the Control category.
Add a forever block
  • Get an if then block from the Control category and put it in the forever block.
Add an if then block
  • Go to the Sensing category and get a touching block. Put that inside the if then block as a condition. Then, change the text from mouse-pointer to wizard-toad, or whatever other sprite you chose for the player.
Add a sensing condition
  • Go to the Control category and drag a stop all block in the if then block.
Add if then block

4. Test your game!

  • Click the green flag to start your game. Can you jump over the enemy sprites and end the game when they collide? 

Your game is complete! 

Take a look at the final product, your Snake Jumper game is complete. Play Snake Jumper.

More Scratch Tutorials & Games

Check out these other fun Scratch project tutorials and games!

Now that you know how to make a sprite jump, you can add it to any of your own projects.

  • Flying Space Cat – Assist Space Cat in its space exploration mission by developing an enjoyable crystal-collecting game using Scratch programming platform.
  • Code a Rocket Landing Game – Finish this Scratch programming tutorial designed for children and create a game where you safely land a rocket.
  • Valentines Day Card Scratcher – Create a Valentine’s Day scratch-off card with a personal touch by following this easy-to-follow Scratch programming tutorial.
  • Holidays Advent Calendar – Use Scratch to program a customized Advent Calendar for the holiday season and gradually unveil presents, treats, or activities to share with your friends and family.
  • Halloween Candy Collector Game – Follow this simple Scratch programming tutorial and create a personalized game where you collect candies on Halloween.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Try a Scratch Coding Class for Kids

CodeWizardsHQ firmly believes that initiating the exploration of technology and programming during childhood can pave the way for future success. We have designed a structured program for elementary school coding, leveraging the power of Scratch to teach coding principles.

In the first course, Animation and Games with Scratch, students delve into essential programming concepts, including variables, loops, and conditionals. By the end of this course, they will possess the ability to create their own games and animations using Scratch. This prepares them for their journey toward a future in the ever-evolving world of technology.

Our coding classes for kids allow children to nurture their skills, unleash their imaginations, and experience the joy of learning!

The post How to Make a Sprite Jump in Scratch appeared first on CodeWizardsHQ.

]]>
How to Make Flappy Bird on Scratch https://www.codewizardshq.com/how-to-make-flappy-bird-on-scratch/ Fri, 28 Apr 2023 19:04:44 +0000 https://www.codewizardshq.com/?p=55986 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is a great tool for kids to learn how to code and it’s completely free! Anyone can use Scratch to make fun games, stories, and animations by dragging and dropping different blocks of code. It’s really easy to use and perfect for beginners who want to be creative and solve problems with coding. In […]

The post How to Make Flappy Bird on Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is a great tool for kids to learn how to code and it’s completely free! Anyone can use Scratch to make fun games, stories, and animations by dragging and dropping different blocks of code. It’s really easy to use and perfect for beginners who want to be creative and solve problems with coding. In this article, I’ll show how to make a flappy bird game on Scratch without any text-based code.

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

In the Flappy Bird game, the player guides a bird through the sky avoiding a series of obstacles. When the bird collides with an obstacle, the game is over. This type of project has proven to be highly interactive and fun in the Scratch classes I’ve taught here at CodeWizardsHQ. In the Elementary School Core Track, students learn how to build their own interactive games while mastering important programming concepts such as variables, loops, and more.

It’s amazing to see how much kids enjoy this type of project and how much they learn along the way.

Complete this Scratch tutorial for kids to build a Flappy Bird game.

completed flappy bird scratch game

Play and remix the Flappy Bird game now. Avoid the obstacles to increase your score.

What you need:

  1. Scratch account: Create a free Scratch account

No coding experience is necessary for this Scratch tutorial. Beginner-friendly for kids ages 8 and up. Give it a try!

Video Tutorial: How to Make Flappy Bird in Scratch

How to Make Flappy Bird on Scratch

  1. Login to Scratch
  2. Create a New Project
  3. Name Your New Project
  4. Choose a Backdrop
  5. Choose a Sprite
  6. Resize and position the sprite
  7. Add the first code block
  8. Set the sprite’s starting position
  9. Add gravity to the game
  10. Make gravity slower
  11. Make the bird fly up
  12. Design the Game’s Obstacle
  13. Animate the Obstacle
  14. Randomly Position the Obstacle
  15. End the Game Upon Collision
  16. Test your game!

1. Login to Scratch

Login to scratch to build flappy bird

2. Create a New Project

  • Once you are logged in, click the blue Create button at the top of the page.
create a new scratch project

3. Name Your New Project

  • Give your project a name, for example, “Flappy Bird Game”. 
  • Then delete the Scratch cat by clicking the trash can icon next to the sprite.
How to Make Flappy Bird on Scratch Name your project

4. Choose a Backdrop

  • Select the Choose a Backdrop option at the bottom right-hand side of your screen.
choose a backdrop
  • When the Choose a Backdrop screen opens up, select a background for your Flappy Bird game. In this tutorial, I chose “Jungle”, but you can choose whatever you’d like!
Choose a backdrop

5. Choose a Sprite

  • Then, go to the Choose a Sprite option, which is next to the “Choose a Backdrop” section.
Choose a sprite
  • Select a bird sprite of your choosing. We selected the Parrot sprite, which is suggested if you want to create a flapping motion for the character.
select parrot sprite

6. Resize and position the sprite

  • Resize your sprite by changing the Size textbox, we changed it to 50 in this tutorial. 
  • Then, click and drag the sprite shown to the left of the game, since the pipes will be moving from the right to the left.
How to Make Flappy Bird on Scratch resize and position scratch sprite

7. Add the first code block

  • Go to the Events category, then click and drag a when green flag clicked events block into your code area.
Add when green flag clicked

8. Set the sprite’s starting position

  • Go to the Motion category and drag a go to x and y block under your when green flag clicked block. This will make sure the player begins at the same place every time the game is loaded.
How to Make Flappy Bird on Scratch Set sprite position

9. Add gravity to the game

  • Then, in the Control block category, drag a forever block and attach it under the go to x and y block.
Add gravity to game
  • Go back up to the Motion category and get a change by y motion block, then drag it directly into the forever block. 
  • Change the value in the textbox of the change by y block to -15. Now when you press the green flag icon above your game, the bird will drop really fast!
Add change position block

10. Make gravity slower

  • To fix the bird from falling so quickly, put a wait block from the Control category before the change y by block. 
  • Change the value in the textbox to about 0.1.
Slow down gravity

11. Make the bird fly up

  • Now let’s make it so the player can interact with the game! Grab a when space key pressed block from the Events category and drag it into the code area.
How to Make Flappy Bird on Scratch When space key pressed block
  • Go to the Motion category and get a change y by block and put it below the when space key pressed block. Now the player can make the bird fly up! NOTE: Check out the bonus after this tutorial which will show you how to make the bird’s wings flap as they fly.
Motion block

12. Design the Game’s Obstacle

  • Click on the paint option from the New Sprite button to create a pipe sprite.
scratch game obstacle
  • Select a color of your choice from the Fill option, then select the square from the list of tools.
Draw obstacles
  • Click and drag the square to create two pillars or tubes that will be obstacles for the game. Reposition and resize the pipes as needed.
draw obstacles

13. Animate the Obstacle

  • Click on the Code tab and drag a when green flag clicked block from the Events category into the code area. Attach a forever block from the Control category.
How to Make Flappy Bird on Scratch animate scratch obstacle
  • Next, go the the Motion category and drag a set y to block, set x to block, and a glide to x and y block inside the forever block. 
  • In the set x to block, change the textbox to say 275. This makes it so the pipes will start on the right side of the screen!
animate scratch motion block
  • Update the glide block to glide for 2 seconds and change the x value to -275, so that it moves to the left of the screen. 
  • Then, in the Motion category, drag a y position block inside of the y value in the glide block.
glide block

14. Randomly Position the Obstacle

  • Test your project, you’ll notice that the pipes stay at the same position every time they move toward the player. 
  • To fix this, go to the Operators category and grab a pick random block and drag it into the set y to block. 
  • Change its values to something like -65 and 65.
position obstacles in scratch

15. End the Game Upon Collision

  • Nothing happens when the parrot collides with the pipe! Let’s get a when green flag clicked block from the Events category and a forever block from the Control category to set this up.
How to Make Flappy Bird on Scratch game collision in scratch
  • From the Control category, get an if then block and put it inside the forever block.
game collision in scratch
  • Then, go to the sensing category and get a touching mouse-pointer block. Drag that into the if then block. 
  • Click the mouse-pointer option to change it to Parrot instead
if then block
  • Go to the Control category and get a stop all block and put that inside the if then block. This will stop the game when the Parrot and pipes collide!
if then block

16. Test your game!

  • The game should stop when the bird collides with the pipes. Check out the completed project here.
completed flappy bird scratch game


Bonus 1 – Adds a points system

1. Create a variable

  • In your Flappy Bird Project, go to the Variables category and right-click on the variable called my variable. It’s right below the Make a Variable button.
  • Then, select the Rename Variable option.
bonus 1 step 1 flappy bird



2. Name the variable

  • In the popup window, type score for the name, then click OK.
bonus 1 step 2 flappy bird

3. Display the Score

  • Then, click the checkbox next to the score variable. This makes the score show up in your game.
bonus 1 step 3 flappy bird

4. Update the score

  • Then, in the Variables category, drag a set score to 0 block right under the when green flag clicked block. 
  • Also get a change score by 1 block and put it under the glide block.
bonus 1 step 4 flappy bird

5. Test the game!

  • Test your game, you should be able to get a score now when you play the game

Bonus 2 – Make the bird’s wings move as you play the game

1. Select the Sprite

  • First, make sure you click the Parrot sprite from the sprites list.
bonus 2 step 1 flappy bird

2. Switch the Sprite’s costume

  • Go to the Looks category and grab a switch costume block for inside the forever block and under the when space key pressed block. 
  • Make sure that you are using parrot-a in the forever block and parrot-b under the when space key pressed block.
bonus 2 step 2 flappy bird

3. Test the Game

  • Do your Parrot’s wings flap? Then, your project is complete, great job!
bonus 2 step3 flappy bird

What is Scratch coding?

Scratch is a block coding language that helps kids learn about computer science. It runs on it’s own web-based platform and is free for anyone to use. It works by taking snippets of code and grouping them into colorful blocks. The blocks can be snapped together to form longer, more complex codes. The more blocks that you use, the more complex the code becomes creating exciting games and apps. It is often used as an educational platform and we highly recommend it for kids ages 8-10 because it doesn’t require strong typing skills. This is a fun and safe coding sandbox for kids to learn fundamental coding concepts and develop their problem-solving and computational thinking. Find out more about Scratch coding for kids.

More Scratch Tutorials & Games

Now that you’ve built your Flappy Bird Game in Scratch, check out these other fun Scratch game tutorials!

  • Flying Space Cat – Assist Space Cat in its space exploration mission by developing an enjoyable crystal-collecting game using Scratch programming platform.
  • Code a Rocket Landing Game – Finish this Scratch programming tutorial designed for children and build a game where you safely land a rocket.
  • Valentines Day Card Scratcher – Create a Valentine’s Day scratch-off card with a personal touch by following this easy-to-follow Scratch programming tutorial.
  • Holidays Advent Calendar – Use Scratch to program a customized Advent Calendar for the holiday season and gradually unveil presents, treats, or activities to share with your friends and family.
  • Halloween Candy Collector Game – Follow this simple Scratch programming tutorial and create a personalized game where you collect candies on Halloween.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Try a Scratch Coding Class for Kids

At CodeWizardsHQ, we believe that learning about technology and programming at a young age can help you succeed in the future. Our coding program for kids in elementary school uses Scratch to teach them how to code.

In the first course, Animation and Games with Scratch, students learn important programming concepts like variables, loops, and conditionals. By the end of the course, kids will be able to make their own Scratch games and animations. This helps them get ready for more advanced coding and a future in technology. Enroll your child in our top-rated coding classes today.

Coding games in Scratch lets kids learn a useful skill while having fun and discovering something new!

The post How to Make Flappy Bird on Scratch appeared first on CodeWizardsHQ.

]]>
How to Add Music to Scratch https://www.codewizardshq.com/how-to-add-music-to-scratch/ Fri, 24 Mar 2023 14:00:00 +0000 https://www.codewizardshq.com/?p=55559 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is a fun and free way for kids to learn how to code. With Scratch, you can create cool games, stories, and animations by dragging and dropping blocks of code. It’s easy to use and perfect for beginners who want to be creative and solve problems. In this tutorial, I will teach you how […]

The post How to Add Music to Scratch appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is a fun and free way for kids to learn how to code. With Scratch, you can create cool games, stories, and animations by dragging and dropping blocks of code. It’s easy to use and perfect for beginners who want to be creative and solve problems.

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

In this tutorial, I will teach you how to add music to Scratch projects. You can choose from the library of background music or add your own audio files to make your project even more exciting. With Scratch, you can let your imagination run wild and make something that you can be proud of. So, let’s get started and make some music in Scratch!

How to Add Music in Scratch

Set a mood with the right song or use sound effects to enhance your game using these simple steps. 

1. Go to Scratch.mit.edu and click “Sign In”

If you don’t have an account, click “Join Scratch” to create one for free.

Sign in to Scratch

2. Create a New Project

Once you are logged in, click the “Create” button at the top of the page.

Create a new Scratch project

Name your project something like “My Drum Kit”. Then, delete the Scratch cat by pressing the trash bin icon next to the cat.

Name your scratch project

3. Choose a Backdrop

Go to the bottom-right of your screen and click on the circular blue “Choose a Backdrop” button.

Choose a backdrop in Scratch


Click on the backdrop of your choice from the options.

Select your background

Recommended: How to Make a Game on Scratch

4. Add an Instrument Sprite

Go to the bottom-right of your screen and click on the circular blue “Choose a Sprite” button.

Type drum into the search bar at the top of the page to find all of the drumkit parts. Start by adding the “Drum Kit” sprite, then the “Drum-cymbal” and “Drum-snare“.

Click and drag these wherever you would like.

Choose a scratch music sprite

5. Add “When This Sprite Clicked” block

Then click on the “Drum Kit” sprite and drag a “when this sprite clicked” block from the Events category (Yellow Blocks) into the code area.

When this sprite clicked block

6. Add “start sound” block

Go to the Sound category, then click and drag the “start sound” block and connect it to under the “when this sprite clicked” block.

When this sprite clicked block

7. Copy Code to Other Sprites

Click and drag this code into the other sprites in the sprites list at the bottom right of the page. This is essentially a copy-paste of your code so you don’t have to find the same blocks for every instrument. When you click on the other instruments, you should then see the same code.

Copy code to scratch sprites

8. Change Each Sprite’s Sound

Click on each sprite and select a different sound in the “start sound” block by clicking on the name of the sound. Now click on each sprite in your drumset to enjoy your music!

Change each sprite's music

Play Background Music in Scratch

You can also play music or sounds continuously in your project using a simple loop.

1. Add a New Sprite

In your project, click the “Choose a sprite” button on the bottom right of the screen. Then select a new sprite, such as a radio, that will play music in the background.

playing background music in scratch, add radio

2. Add a “when this sprite clicked” block

From the Events category, click and drag a “when this sprite clicked” block into the code area.

when this sprite clicked block

3. Add “play sound until done” block

Next, go to the Sound category and drag a “play sound until done” block into the “forever” block.

play until done block

4. Add a “set volume to” block

You can also control how loud the background music is by using a “set volume to” block in the Sounds category. Put this above the “forever” block. You can change how loud it is by changing the value in the textbox to less than 100.

set volume to step 4

5. Edit in the “Sounds” tab

Click on the “Sounds” tab on the left side of the screen, above where the code blocks are. This is where you can find and edit sounds for your project!

Scratch sounds tab

6. Choose a Sound

In the “Sounds” tab, click on the circular blue “Choose a Sound” button on the bottom-left of the screen.

Choose a sound

7. Add a loop

Click on the “Loops” category and click a sound you like. A loop is a repeating section of sound or music.

Add a music loop

8. Update “play sound until done” block

Click on the “Code” tab and edit the “play sound until done” block to have the new sound.

play sound until done block

9. Start the music

Now, click on the radio to start the background music! Have fun playing alongside the music with your drum set.

add music loop in scratch


Add Custom Audio in Scratch

Record your own audio, like your voice or favorite instrument, using a microphone and add it to your Scratch project.

1. Choose a Sound

Click on the instrument in your project you want to add the custom sound to. Then, click on the “Sounds” tab.

Sound tab in scratch

2. Select Record

Go to the circular blue “Record” button on the bottom-left of the screen.

record music

3. Allow your microphone

There might be a pop-up asking if Scratch can use your microphone in your browser. Click Allow.

Allow your microphone

4. Record Your Audio

Click the “Record” button and when you are done, click “Stop recording“. Then, click the “Save” button.

Record your music in scratch

7. Update “start sound” block

Go back to the “Code” tab and click on “recording1” in the “start sound” block. You’ve just made your own custom audio!

start sound block

Try adding music to some of these projects!

  • Flying Space Cat – Assist Space Cat in its space exploration mission by developing an enjoyable crystal-collecting game using Scratch programming platform.
  • Code a Rocket Landing Game – Finish this Scratch programming tutorial designed for children and create a game where you safely land a rocket.
  • Valentines Day Card Scratcher – Create a Valentine’s Day scratch-off card with a personal touch by following this easy-to-follow Scratch programming tutorial.
  • Holidays Advent Calendar – Use Scratch to program a customized Advent Calendar for the holiday season and gradually unveil presents, treats, or activities to share with your friends adn family.
  • Halloween Candy Collector Game – Follow this simple Scratch programming tutorial and create a personalized game where you collect candies on Halloween.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Intro to Scratch Coding

At CodeWizardsHQ, we know that getting started with technology and programming early on is important for success. Our elementary school coding program uses Scratch to introduce students to programming and get them excited about coding.

In our first course, Animation and Games with Scratch, students learn key programming concepts like variables, loops, and conditionals. By the end of the course, they will be able to create their own games and animations using Scratch. This prepares them for more advanced coding and a bright future in the world of technology. Our elementary school coding program allows students to develop their skills and creativity while having fun and learning something new!

Ready to level up your child’s learning experience? Take a coding class with CodeWizardsHQ:

The post How to Add Music to Scratch appeared first on CodeWizardsHQ.

]]>
How To Make A Good Scratch Animation https://www.codewizardshq.com/scratch-animation/ Tue, 21 Feb 2023 06:38:26 +0000 https://www.codewizardshq.com/?p=55038 Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is an innovative and interactive way for children to learn how to program animations. It provides a platform to express creativity while also developing valuable technical skills. Your child will be able to bring their imagination to life by creating animations, games, and stories using blocks that can be dragged and dropped onto the […]

The post How To Make A Good Scratch Animation appeared first on CodeWizardsHQ.

]]>
Online coding academy for kids and teens ages 8-18. Enroll to learn real-world programming languages like Python, Java, HTML/CSS, JavaScript, and more!

Scratch is an innovative and interactive way for children to learn how to program animations. It provides a platform to express creativity while also developing valuable technical skills. Your child will be able to bring their imagination to life by creating animations, games, and stories using blocks that can be dragged and dropped onto the screen.

📌 [Download] Printable Scratch Coding Tutorials Get 2 printable Scratch tutorials, Rocket Landing and Flying Space Cat, to code your own games step by step. Download Now

Not only is Scratch fun and engaging, but it also helps with problem-solving skills since coding requires the ability to break down a problem into smaller parts, think logically, and find creative solutions. Learning to code with Scratch can also improve your child’s critical thinking, creativity, and communication skills, making it a well-rounded educational experience.

What is Scratch animation?

Animation is the method by which still figures are manipulated to create the illusion of movement. Besides film and tv, animation is also widely used in websites, games, and apps.

Scratch is a great option for kids who want to learn animation because it provides a fun, accessible, and interactive way to learn the basics. The Scratch platform is designed specifically for young people and provides a visual interface that makes it easy for kids to get started with coding.

With Scratch, kids can create animations by simply dragging and dropping blocks of code. The blocks represent actions, such as moving a character or changing the background, that can be combined to create a complete animation.

One of the great things about Scratch is that kids don’t need any prior experience with coding or programming. The visual interface makes it simple for kids to understand how the code works and the drag-and-drop interface makes it easy to build animations without getting bogged down in complex syntax.

Another advantage of Scratch is its community aspect. Kids can share their animations with others, get feedback, and even collaborate on projects with other Scratch users from around the world. This makes it a fun and social way for kids to learn and create together and provides a supportive environment for them to explore and develop their coding skills.

Make your first Scratch animation!

Running Unicorn Animation

Let’s take a unicorn image and animate it in Scratch.

Step 1 – Login to Scratch

  • Login to your account at scratch.mit.edu.
  • Click the Sign In button located in the top-right corner of the page, then input your username and password.
scratch animation step 1 sign in

Step 2 – Create a New Project

  • Start a new project by selecting the Create button on the top of the screen.
scratch animation step 2 create project

Step 3 – Name Your Project

  • Give your project a name using the textbox at the top of the page.
scratch animation step 3 name project

Step 4 – Delete Cat Sprite

  • Delete the cat character by navigating to the sprite section at the bottom-right of the page and selecting the blue trash can icon next to the sprite.
scratch animation step 4 delete cat sprite

Step 5 – Search Backdrop

  • Click the blue backdrop button on the bottom-right of the page. This is so you can choose a background for your animation!
scratch animation step 5 backdrop

Step 6 – Add Blue Sky Backdrop

  • Choose whichever backdrop you’d like by clicking it. For example, we are using the Blue Sky backdrop.
scratch animation step 6 select backdrop

Step 7 – Add Sprite

  • Click the Sprite button at the bottom-right of the page next to the Backdrop button.
  • Then click the Magnifying Glass from the list of options. This is so we can add the unicorn sprite.
scratch animation step 7 choose sprite

Step 8 – Search and Select Unicorn Running Sprite

  • In the search bar, enter Unicorn and select the Unicorn Running sprite from the options.
scratch animation step 8 select sprite

Step 9 – Position Unicorn Sprite

  • Position the unicorn on the screen where you would like by clicking and dragging it in the stage area. Make sure to click the Save Now button on the top-right of your screen, near your account picture.
scratch animation step 9 position block

Step 10 – Add When Green Flag Clicked Block

  • Go to the code blocks on the left of your screen and click the Events category.
  • From there, you will click and drag a When Green Flag Clicked block into the script area.
scratch animation step 10 add green flag

Step 11 – Add Forever Block

  • Go to the Control category, then click and drag a Forever block into the script area. The Forever block repeats a set of code forever, or until the Red Stop Button is clicked.
scratch animation step 11 forever block

Step 12 – Switch Costumes

  • Go to the Looks category and select a Next Costume block.
  • Then, Go to the top of the page and click the Green Flag to test your project.
scratch animation step 12 costume block

Step 13 – Add Wait Block

Your unicorn runs now! But you might notice that it runs quickly, so to slow it down we can use a Wait block.

  • Go to the Control category, click, and drag a Wait block into the Forever block. You can change the value in this block by editing the number in the textbox. This allows a short delay before each costume change, creating a smooth animation.
scratch animation step 13 wait block

Great job! Click the green flag again to watch your unicorn run in this simple animation.

To view or remix the finished animation, click here.

Bonus Round: Make a scrolling background

Use the same project and try animating the background too.

Step 1 – Add New Sprite

  • Click on the New Sprite button on the bottom-right of the page and click the Magnifying Glass from the popup menu.
  • Then, search for Tree in the Textbox and select one of the options.
scratch animation bonus step 1 add sprite

Step 2 – Position Tree Sprite

  • Click and drag the tree all the way to the right of the page. This will be the starting point every time the tree goes by.
scratch animation bonus step 2 position

Step 3 – Add When Green Flag Clicked Block

  • In the tree sprite, go to the Events category and click and drag a Green Flag Clicked block into the scripts area.
  • Then, go to the Control category and connect a Forever block to it.
scratch animation bonus step 3

Recommended: How to Make a Game on Scratch

Step 4 – Position Tree After Motion

  • Go to the Motion category and select a Go To block. This will help us to reset the tree’s position after it moves.
scratch animation bonus step 4

Step 5 – Move Tree

  • Go to the Motion category, insert a Glide block inside the Forever block.
  • Change the x value (first number) to its negative equivalent. If the x value is 298, make it -298 so the movement will be towards the left side of the screen.
scratch animation bonus step 5

Step 6 – Position Tree Behind the Unicorn

The tree glides in front of the unicorn. To make it glide behind the unicorn, we need to position it behind.

  • Go to the Looks category and scroll down until you see the Go to Front Layer block.
  • Drag that under the Green Flag Clicked block, but above the Forever block. Now the tree will be behind the unicorn as it is running!
scratch animation bonus step 7 front layer

Step 7 – Run Your Animation

  • Click the green flag to run your animations.
scratch animation unicorn running

Great job making this Scratch animation! To publish this project for others to see, check out this tutorial.

View or remix the finished unicorn animation.

Common Types of Animations

Scratch provides numerous animation possibilities for users to experiment with, from short films to sprite animations and music videos. The creation of these animations typically involves programming sprites to move, speak, and interact with each other through various methods. There are countless options for users to discover and create their own unique animations.

Here are some of the most popular types of animations on Scratch:

3D Animations – Stop motion animation is utilized in this technique, which involves importing numerous frames of a 3D object made in a 3D application like Blender. They will be played in quick succession within Scratch to achieve a 3D rotation effect.

Animated Music Videos – This type of animation features a song playing in the background, with the animation of a sprite lip-syncing and/or dancing to the music, often with multiple scenes included.

Speedpaint – These depict the creation of artwork over a period of time. The process involves the artist drawing a small section of the piece, duplicating it, and then adding a little more before repeating the process until the artwork is complete, which can require many costumes in the project.

Sprite Animations – This type of animation uses pixel art sprites and is similar to regular animations, but they use pre-existing 8/16-bit video game sprites. Characters from well-known franchises such as Mario, and Sonic the Hedgehog are frequently used.

Animation Series – This animation style usually features a storyline and can span multiple episodes or scenes. One can either voice the characters themselves or utilize text-to-speech.

To see other types of animations, see Animation Projects in Scratch.

Scratch Animation Project Examples

The Scratch Animation Projects Page is home to a wide variety of projects created by students from all around the world. It’s a fantastic place to see what can be achieved with Scratch and to find inspiration for your own projects.

Here are five of my favorite projects that showcase the creativity and ingenuity of the Scratch community:

  1. Uno Card Game Animation – Two friends are playing Uno, but one of them is doing much better than the other!
  2. Yoshi Dance Animation – This animated scene features Yoshi dancing to the tune of “Cha Cha Real Smooth”.
  3. Minecraft in a Nutshell Animation – This animation describes different elements of the Minecraft game with examples.
  4. Recycling Animation – Two friends have a discussion about the importance of recycling.
  5. Lightsaber Laboratory 2 – This animated scene is more interactive and lets you play around with a lightsaber by changing its properties and trying it out.

Download Free Printable Scratch Coding Tutorials PDF

Get the Rocketship Landing game and Flying Space Cat Scratch tutorials in a printable format.

Code Your Own Scratch Animations

At CodeWizardsHQ, we believe that the key to unlocking a child’s potential lies in early exposure to technology and programming. Our elementary school coding program is designed to do just that! With a focus on Scratch, we introduce young students to the exciting world of programming. The first course in our elementary school program, Animation and games with Scratch, allows students to learn important programming concepts like variables, loops, and conditionals. By the end of the class, they’ll be coding their own games and animations and well-prepared to take the next step in their programming journey!

Ready to level up your child’s learning experience? Take a coding class with CodeWizardsHQ:

The post How To Make A Good Scratch Animation appeared first on CodeWizardsHQ.

]]>