How to Make a Platformer in Scratch | Zinnea | Tutorial

Alphabets Sounds Video

share us on:

In this lesson, you will learn how to create a platformer game in Scratch, focusing on smooth character movement, jumping mechanics, and gravity simulation. You’ll implement features like variable speed control, friction for realistic movement, and the basics of vertical movement with gravity, setting the stage for more advanced elements like collision detection in future lessons. By the end, you’ll have a foundational understanding of how to build and enhance a platformer game.

How to Make a Platformer in Scratch

Hey everyone! Today, we’re going to learn how to make a platformer game using Scratch. By the end of this tutorial, you’ll know how to create a game where a character can move, jump with gravity, avoid obstacles, and even have multiple levels. Let’s dive in!

Getting Started with Movement

First, we’ll make our character move smoothly. In many games, characters move a set amount when you press an arrow key. But in a platformer, we want smoother movement. When you press an arrow key, the character will get a speed boost in that direction, which will slowly decrease over time.

To start, drag out a forever block in Scratch. This block will make your character continuously change its position. We’ll make the character change its X position by a certain amount each tick of the game. You can control how fast the character moves by changing this number. For example, setting it to 1 makes the character move slowly, while setting it to 10 makes it move very fast.

Using Variables for Speed

Instead of changing numbers manually, let’s create a variable called “X speed.” This variable will control how fast the character moves. When you press the right arrow key, increase the X speed by 1. Place this inside the forever loop to keep checking if the right arrow is pressed.

Now, when you press the right arrow, the X speed increases, and the character moves. To make the character move in both directions, decrease the X speed by 1 when the left arrow is pressed.

Smooth Movement with Friction

One problem you might notice is that once you start moving in one direction, you have to press the opposite arrow key to slow down. To fix this, we’ll make the X speed naturally decrease over time, simulating friction. Use the set X speed block and multiply it by a number less than 1, like 0.9. This will gradually bring the speed back to zero.

Now, when you press the right arrow, the character moves right, but eventually slows down. The same happens when moving left. This gives us smooth movement, just like in real life!

Adding Gravity and Jumping

Next, let’s add gravity. Create a block called “move left and right” to organize your code. Then, create another variable called “Y speed” for vertical movement.

To make the character jump, set the Y speed to a high value, like 10, when the up arrow key is pressed. After checking for the up arrow, change the Y position by the Y speed.

To simulate gravity, decrease the Y speed by a negative number, such as -1. This way, even if the character jumps upward, gravity will eventually pull it back down.

Fixing Common Issues

You might notice some issues, like the character falling through the ground or jumping without a surface. In the next part of the series, we’ll learn how to fix these problems by adding collision detection with the ground and platforms.

I hope this helps you get started with your platformer game. Have fun creating, and see you next time in Scratch!

  1. What aspects of creating a platformer game in Scratch did you find most challenging, and how did you overcome these challenges?
  2. How did the concept of using variables for speed enhance your understanding of programming in Scratch?
  3. Reflect on the process of implementing smooth movement with friction. What insights did you gain about simulating real-world physics in a game environment?
  4. In what ways did adding gravity and jumping mechanics change your approach to game design in Scratch?
  5. What strategies did you use to troubleshoot and fix common issues like falling through the ground or jumping without a surface?
  6. How did organizing your code with blocks, such as “move left and right,” affect your workflow and code readability?
  7. What new skills or concepts did you learn from this tutorial that you plan to apply to future projects in Scratch?
  8. How do you think the experience of creating a platformer game in Scratch can influence your understanding of more complex programming languages and game development tools?
  1. Design Your Character

    Start by designing your own character sprite in Scratch. Use the costume editor to create a unique look for your character. Think about what kind of character you want in your game and how it might move. Once you’re happy with your design, save it and get ready to bring it to life with movement!

  2. Experiment with Movement

    Use the forever block to make your character move. Experiment with different values for the “X speed” variable to see how fast or slow your character can go. Try pressing the arrow keys and observe how the character moves. Adjust the values to find the perfect speed for your game.

  3. Create a Friction Effect

    Implement the friction effect by multiplying the “X speed” by a number less than 1. Notice how this changes the movement of your character. Does it feel more realistic? Try different friction values to see how they affect the gameplay. Discuss with your classmates why friction is important in a platformer game.

  4. Simulate Gravity

    Add gravity to your game by creating a “Y speed” variable. Test how your character jumps and falls by adjusting the Y speed. Make sure to test jumping from different heights and see how gravity affects the movement. Share your findings with the class and see how others have implemented gravity in their games.

  5. Build a Level

    Design a simple level with platforms and obstacles using Scratch’s backdrop editor. Place your character on the level and test how it interacts with the platforms. Use the skills you’ve learned to ensure your character can move, jump, and land on platforms correctly. Challenge your classmates to play your level and provide feedback on the gameplay.

Here’s a sanitized version of the YouTube transcript:

Hey everyone, it’s Zenia here! Today, I want to show you how to make a platformer in Scratch. By the end of this series, you’ll be able to create your own game with a moving character, gravity, areas the player has to avoid, multiple levels, and more. So let’s get started!

In this first video, I will show you how to make the character move around and jump with gravity. In previous games I’ve made, we’ve usually done movement by having the character move a set amount in a direction when an arrow key is pressed. To achieve the smooth movement that platformers have, we’ll think about movement differently: when you press an arrow key, the player gets a speed boost in that direction, which then gradually wears off.

To start making the character move, I will drag out a forever block and make the character continuously change X by one. This means that every tick of the game, the character moves by one step. I can control how fast the player moves by changing this number. If I set it to zero, the character won’t move at all. Setting it to one makes it move slowly, three makes it faster, and ten makes it extremely fast.

Instead of typing different numbers to change the speed, I will create a variable to let the player increase this number. I will call this variable “X speed.” When the right arrow key is pressed, I will increase X speed by one. This will be placed inside the forever loop to continuously check if the right arrow is pressed.

Now, when I press the right arrow, X speed increases. However, the character still isn’t moving because it still says to change X by zero. To fix this, I will drag X speed into the change X block. Now, when I press the right arrow key, it increases X speed, and the player moves accordingly.

Currently, we can only move in one direction, so let’s fix that. If the left arrow is pressed, I will decrease X speed by one. Now, we can move in both directions.

One issue you may notice is that once you start going in one direction, you have to switch to the other direction to slow down. To address this, I will make it so that X speed naturally decreases a little bit over time. I will use the set X speed block and multiply it by a number less than one, like 0.9. This will gradually decrease the speed towards zero.

Now, when I press the right arrow, I can move right, but eventually, my speed goes back down to zero. I can also move left, and the same thing happens. This gives us smooth platformer movement, simulating friction on the ground.

Next, let’s add gravity. To organize my code, I will create a block called “move left and right” and place the relevant code inside it. Now, I will create another variable called “Y speed” to handle vertical movement.

To make the character jump, I will set Y speed to a high value, like 10, when the up arrow key is pressed. After checking for the up arrow, I will change Y by Y speed.

To implement gravity, I will decrease Y speed by a negative number, such as -1. This means that even if we jump upward, gravity will eventually pull the character down.

You might notice a couple of issues, such as the character falling through the ground and being able to jump without a surface. I will show you how to fix these issues and more in part two of the series, where I’ll demonstrate how to add collision with the ground and platforms.

I hope this helps you get started with your platformer, and I’ll see you next time in Scratch!

This version removes informal language and clarifies the instructions while maintaining the original content’s intent.

ScratchA visual programming language that allows you to create games and animations by snapping together code blocks. – In Scratch, I made a game where a cat chases a mouse around the screen.

PlatformerA type of video game where the player controls a character to jump between platforms and avoid obstacles. – My favorite platformer game has levels where you have to jump over lava pits and climb tall mountains.

CharacterA person, animal, or object that you can control in a game or animation. – I designed a character in my game that can fly and shoot lasers.

MovementThe action of changing position or location in a game, often controlled by the player. – The movement of my game character is controlled by the arrow keys on the keyboard.

SpeedHow fast a character or object moves in a game. – I increased the speed of the car in my racing game to make it more challenging.

GravityA force in games that pulls characters or objects downwards, similar to how gravity works in real life. – In my platformer game, gravity makes the character fall back to the ground after jumping.

JumpThe action of moving upwards off the ground, often used to avoid obstacles or reach higher platforms in games. – I programmed my character to jump over the rolling barrels in the game.

VariableA storage location in programming that holds a value which can change during the game. – I used a variable to keep track of the player’s score in my game.

FrictionA force in games that slows down the movement of characters or objects when they slide across surfaces. – I added friction to the ice level in my game so the character slides around.

ObstaclesThings in a game that block the character’s path and must be avoided or overcome. – The obstacles in my game include spikes and moving platforms that the player must dodge.

All Video Lessons

Login your account

Please login your account to get started.

Don't have an account?

Register your account

Please sign up your account to get started.

Already have an account?