• Blog Images Aron John
  • 09 May, 2022
  • 4 min read

How To Make A Platformer On Scratch

What is the definition of a platform game? This popular style of video game, sometimes known as a platformer, has a figure navigating between platforms or over obstacles. One of the most well-known examples of this is Super Mario Bros. You'll be well on your way to creating your own entertaining games in just a few easy steps! Scratch is a fun and easy-to-use tool for learning to code. Coders of all ages may express their creativity by creating their own games, animations, and dynamic stories. It's a natural (and motivating) approach for youngsters to learn to code since it's a high-level type of programming language in which you construct programs using colorful drag-and-drop blocks rather than text-based code. Platform game design is ideal for learning about level design, sprite movement, and other aspects of game development. Scratch is an easy-to-use programming language for children ages eight and under. Make your sprites first, sprites are utilized to construct the character, ground, and platforms in a platformer. For a terrific intro to sprites and much more about Scratch 3.0, go visit the Scratch Wiki!

Step 1 : Choose A Character

Just use Scratch Cat or another preset sprite if you like. To change your sprite, go to the bottom right corner of your screen and click the "Choose a Sprite" button. For greater personalization, you may even change costumes. "Sprite" should be renamed "player." Then, if you're not using it, remove the Scratch Cat with a right-click. Reduce the player's size to provide space for movement around the game screen. You'll need to program movement into your new persona. Learn how to create a sprite move using Scratch blocks to brush up on your scripting skills! Also, remember to rename your game. Come up with a catchy title using your imagination! Next, make a basic ground sprite. To make it easier to identify, rename a new sprite "ground." Fill the bottom width of the drawing window with a ground block. Finally, make basic horizontal platforms for running, hopping, and jumping. This is what adds to the enjoyment of a platformer game! Keep in mind that as you get experience constructing your own games, you may create varied (and unique) forms. Make your first platform with a new sprite. Make a copy of this and call it "platform 1" for additional platforms ("platform 2" and so on). To keep things basic, start with two or three. Now your sprites are ready, awesome!

Step 2: Write A Basic Sprite Script.

Gravity is a crucial component of every platform game. It determines whether your character will fall off of platforms and other barriers (as well as whether they will fall on the ground, on a platform, or in the air). A basic block script for your platformer sprite may be seen above. During gameplay, your avatar will be able to travel along the ground, onto platforms, leap into the air, and fall back to the ground. In Gravity we can see only two different variables. One is "gravity" (this includes the value which determines the impact of falling) and the other is "x velocity" (this determines the speed in which the object falls horizontally). Begin with a block that says "when the green flag is clicked." Then, at the bottom, add a "forever" block. As seen in the above figure, insert the different additional blocks (with associated values). The "change y by" section at the bottom of the script includes "gravity" (falling), whereas the "change x by" section has "x velocity" (horizontal speed).

Step 3: Persuade Your Character To Take A Chance.

Isn't it true that you can't play a game if your character remains motionless? Let's get this party started! Begin by dragging a "when green flag clicked" block into place. Then, underneath it, insert a "forever" block and a "if () then" block within the forever block. (Blocks put together in this manner generate a Forever Loop, which means it cycles over blocks indefinitely throughout gaming.) As you can see, you'll have to add a "key () pressed? then" block to select the "up arrow" for leaping so that your character can leap. (Note that the "change x by ()" block moves your character to the left and right, while the "change y by ()" block moves them up and down.) Your character's vertical position is known as the Y position. It is in the middle of the stage if the value is 0. It is at the top with a value of 180 and at the bottom with a value of -180.

Step 3: Persuade Your Character To Take A Chance.

Isn't it true that you can't play a game if your character remains motionless? Let's get this party started! Begin by dragging a "when green flag clicked" block into place. Then, underneath it, insert a "forever" block and a "if () then" block within the forever block. (Blocks put together in this manner generate a Forever Loop, which means it cycles over blocks indefinitely throughout gaming.) As you can see, you'll have to add a "key () pressed? then" block to select the "up arrow" for leaping so that your character can leap. (Note that the "change x by ()" block moves your character to the left and right, while the "change y by ()" block moves them up and down.) Your character's vertical position is known as the Y position. It is in the middle of the stage if the value is 0. It is at the top with a value of 180 and at the bottom with a value of -180.

Step 4: Create a Background

Choose or sketch a background for your game to give it a professional appearance. The Backdrops Library contains default backdrops. For the sake of this scratch lesson, please choose a ready-made background. You are free to make your own later. Allow your imagination to go wild. Draw trees, a castle, the sun, anything you want to personalize the platformer! You should keep in mind that you already have a ground sprite. In the game view, make sure the ground and background complement each other.

Step 5: Put Your Learning to the Test

Now comes the exciting part! After you've built up your character, ground, levels, and code blocks, double-check that your game is working correctly by making sure that all of the buttons correlate to the required actions! You've Achieved Your Goal! Continue to practice now. You did an excellent job! You've learned how to construct a simple platform game. Continue to learn new gaming tactics and approaches. Your creation may even be shared with the Scratch community.There's a lot of fun to be had! For more informative articles like this, visit codingforkid.com Join Cyber Square to get your child started on his or her coding path. Enroll Now on coding for kids provides the best coding classes in kids.

Author Images
Aron John

Aron Jhon is an author, blogger, and designer living in a suburb of Washington, DC. When he's not designing, blogging, or writing, Aron can be found with her head in a book or pinning like a madman :)