Create Platformer on Scratch 3.0
Today, we’re going to show you how to make a basic platformer on Scratch from scratch!
What is a platform game? Also called a platformer, this popular type of video game features a character moving to and from platforms or over obstacles. One of the all-time greatest examples is Super Mario Bros. With a few simple steps, you’ll be on your way to making your own fun games!
Why Make a Platform Game?
As highlighted in our What is Scratch Coding article, Scratch is a user-friendly application for coding practice and creative fun. Coders of all ages can let their imaginations run wild through their own games, animations, and interactive stories!
As a high-level visual programming language—you create with colorful drag-and-drop blocks instead of text-based code—it’s an intuitive (and inspiring) way to learn coding for kids.
Platform game design is great for exploring level design, sprite movement, and more. Recommended for children over the age of 8, Scratch makes it easy!
What You Need to Start
New to Scratch 3.0? All you need is a device (laptop, desktop, or tablet), web browser, internet connection, and Scratch accountto run it.
Once set up, a coder age 8+ is ready to learn Scratch programming language.
Platforming games work with more complex concepts, including gravity and physics. This helps Scratchers improve their logical and creative thinking skills.
If you’re completely new to Scratch, here are basic Scratch tutorials to get started:
-
Getting Started Coding in Scratch (first Scratch project)
-
How to make a Scratch sprite jump (an essential game mechanic)
-
How to Make a Scratch Game (step by step)
Don’t be nervous, though. Once you get the hang of the basics, it’s simple & fun to make a game in Scratch!
Ready to make your first basic platformer game? Good luck!
Platformer Game Tutorial
Step 1: Make Your Sprites
In a platformer, sprites are used to create a character, ground, and platforms. Check out the Scratch Wiki for a great introduction to sprites and more about Scratch 3.0!
First, select a character.
Feel free to use the Scratch Cat or another premade sprite. To select a new one, click the button labeled “Choose a Sprite” located in the lower right corner of your screen. (You can also switch costumes to add even more customization.)
Rename “sprite” to “player.” Then, delete the Scratch Cat with a right click (if you’re not using). Decrease size of player to allow room for moving around the game screen.
You’ll need to program your new character for movement. Check out how to make a sprite move to freshen up on scripts with Scratch blocks!
Remember to rename your game, too. Get creative with the title!
Next, make a simple ground sprite. Select a new sprite and rename it “ground” for clear labeling. Draw a ground block that fills the bottom width of the drawing window.
Finally, create simple horizontal platforms on which to run, hop, and jump. This is what makes a platformer game fun! Keep in mind that you can make different (and unique) shapes as you get more comfortable building your own games.
Select a new sprite and draw your first platform. Name this “platform 1” and duplicate it for new platforms (“platform 2” and so on). Start with two or three to keep things simple.
Got your sprites ready? Awesome!
Step 2: Create Simple Sprite Script
Gravity is an important element for any platform game. It controls your character’s tendency to fall off of platforms and other obstacles (as well as determining whether it’s on the ground, platform, or in the air.)
Above, there's a simple block script for your platformer sprite. This will allow your character to move along the ground, onto platforms, jumping in the air, and falling back onto the ground during gameplay.
For gravity, there are two new variables. One is "gravity" (which holds the value strength of falling) and "x velocity" (which holds the value of horizontal speed).
Start with a "when green flag clicked" block. Then add a "forever" block to the bottom of it. Insert the various other blocks (with corresponding values) as shown in the above image.
Towards the bottom of the script, the "change y by" contains "gravity" (falling), while the "change x by" contains "x velocity" (horizontal speed).
Step 3: Make Your Character Jump
Can’t have a game if your character stands still, right? Let’s get it moving!
To make your character jump, use the above code.
To begin, drag in a “when green flag clicked” block. Then add a “forever” block below it and place an “if () then” block inside the forever block.(Blocks inserted in this way create what’s called a Forever Loop, which means it constantly loops through blocks during gameplay).
As you can see, to make your character jump, you'll need to add a "key () pressed? then” block to select the "up arrow" for jumping.
(Note: The "change x by ()" block moves your character left and right, while the "change y by ()" block moves your character up and down.)
Y Position is where your character is located vertically. A value of 0 places it at the middle of the stage. A value of 180 puts it at the top, and a value of -180 positions it at the bottom.
There you go... you're moving and grooving now!
Step 4: Create Backdrop
To give your game a great look, select or draw a backdrop!
Default backgrounds can be found in the Backdrops Library. Categories include All, Fantasy, Indoors, Music, Outdoors, Patterns, Space, Sports, and Underwater.
For the purpose of this Scratch tutorial, please select a premade backdrop.
Later on, you can make your own. Let your imagination fly. Draw trees, a castle, the sun… whatever makes the platformer your own!
Remember that you already have a ground sprite. Make sure the ground and backdrop work well together in the game view.
Step 5: Test Your Game
Now, the fun part! Once you’ve set up your character, ground, platforms, and code blocks, double-check your game is running properly:
- Left and right movement
- Jumping movement with up key
- Running animation (on ground, not in air)
- Jumping from ground to platforms (up key)
- Dropping down from platforms (down key)
Everything working well? Congratulations!
Once you’ve mastered the basics, you can level up with objects to collect and a scrolling platformer feature (or multiple levels) for added challenge.
You’ve Made It! Now Keep Practicing
Great job! You now know how to make a basic platform game. Continue to discover new techniques and game strategies. You can even share your project with the Scratch community. There’s so much fun stuff to do!
Read more about how Juni teaches coding for kids, or speak with a Juni Advisor by calling (650) 263-4306 or emailing advisors@learnwithjuni.com.
You can also read more about how we use Scratch to teach beginner coding.