A platformer game can be regarded as the simulation of real physics taking place in real life. Objects tend to move, fall, jump, bounce, and slide. As such, a platformer associates the given properties into the game in which one would control a character while trying to move the same towards the goal. Get to know more about how to make a scratch platformer game through our scratch beginners course, available now for 25% discount using this special code

scratch programming for beginners - scratch platformer tutorial

Creation of the Platformer Sprite on Scratch

The platformer sprite serves to be the “Avatar” that is controlled by the respective player. Its overall appearance can impact the existing gameplay slightly. It would ultimately depend on size and angles of the respective Costumes. For instance, a character should not be protected from the fall due to the brim of the hat snagging on the cliff’s edge. Sprites that tend to be animated by several costume changes tend to be quite tricky. This is because the changing costume can be pulled inside the wall or ground while getting stuck.

Here is an example of a simple script indicating the platformer sprite. It makes use of two vital variables, as described in the list below:

  • X Velocity –it is responsible for storing a value for representing the horizontal speed of the sprite. It has been set as a local variable by inspecting the option “for this sprite only” during the creation Dialog. This implies that
  • the variable can be changed only by scripts in the given sprite
  • the variable name would not without any need clutter the respective variable pane of the subsequent sprites
  • the same variable name could be utilized in other sprites without leading to conflicts
  • Gravity –it helps in storing a value for reflecting the overall strength of the tendency of the sprite to fall. In the given example, the same has been set to a negative value. This is because moving the sprite in the downward direction would require making the value of the Y position quite smaller. Gravity is not required to be set in the form of a local variable. A realistic form of game would be subject to all the subsequent characters to the similar gravitational force.
scratch sprite avatar creation block code example

Making Different Levels using the Scratch programming interface

Colors could be utilized in the given platform for the purpose of detecting the end of a specific level. It could also be utilized for detecting some object sending one back to the start of the given level. For the given Scratch games tutorials, let us assume the given instances:

  • The character sprite would be performing the physics –referred to as the Player
  • Black serves to be the color of the platform, or walls & grounds –within which the character is not able to pass through
  • Red serves to be the color for sending one back to the start of the level on which they were present previously
  • Yellow serves to be the color that is expected to be reached for moving on to the next level
  • Backgrounds are made use of in the form of levels rather than sprites
  • Scrolling does not tend to be incorporated

Example starting point shown in the diagram below;

create scratch platformer level

The shapes are not required to be geometric. However, these can be organic. This implies that some unordinary or inconsistent structure other than a square, rectangle, octagon etc can also be considered. There could be the presence of some curvature of multiple platforms or colors. These can be utilized for the creation of numerous, diverse levels. Here is an example of the utilization of some organic shapes in the platformer.

organic irregular shapes in scratch programming platformer

When the subsequent levels get finished, you can consider adding the following script to the sprite named “Player.”

The scripts that are situated within the loop labeled “forever” could be easily merged with the large physical script. When you tend to merge different scripts, it would help in reducing the total number of conditions that are being checked all at once while having the possibility of making the given project orderly and more uniform. This implies that the Player would make the respective movement while checking for the respective conditions rather than the conditions that are possibly being checked during the movement of the sprite.

It is important to note that a condition is referred to as the statement that gets checked for the true/false response. In the example as mentioned above, when the sprite would be checking whether or not it is touching a specific color, if the same is checking some condition. Later on, the following statements can be added to the Player sprite:

Creating the Win Background

Lastly, the win background comes into the scenario. After all the subsequent levels have been finished in the platformer, something would pop up on the screen displaying “You Win!” You can out the same as the last costume in the background or sprite. It could be some form of text in the simple white background revealing “You Win” message.



Written by Max

Leave a Comment

Your email address will not be published. Required fields are marked *