UnicMinds

Online Scratch Classes for Kids

Building Mario Game in Scratch

Scratch is a simple and great GUI-based platform invented by the Lifelong Kindergarten Group at MIT for children to learn coding while building games and apps. It is a great starting point for newbie-coders to begin learning the fundamentals of programming constructs. Scratch is also the most liked and most popular platform in the world that enables children to play around and learn with aspects of visual thinking, spatial coordination and navigation, design, character creation, imagination, logic, sequence, behavior, and mathematics.

A typical game in Scratch is the Mario game, which involves a character jumping around and moving forward and there will be a set of obstacles that the player has to dodge and navigate around them. Mario has to collect stars and cross obstacles while saving himself from Gumba. There are two levels of difficulty coded by the student in this game. There are powers that Mario gains that makes him invincible.

Creation of the Mario sprite: 

The Mario sprite moves right or left and jumps up to avoid obstacles they encounter.

1) Import a sprite to add the Mario sprite.

2) Choose the Mario sprite which has the below three types:

3) Starting to write the code for the Mario Sprite program:

– Logic for Initial Position:

At the beginning, we switch the Mario sprite to the first costume and place it in the initial position:

– Logic for touching:

If the Mario sprite touches an obstacle, the game stops:

– Logic for jumping:

If the up arrow on the keyboard is pressed, the Mario sprite jumps up while changing his costume to show that he is jumping:

– If the left arrow is pressed, the Mario sprite moves left while changing his costume to show that he is starting to walk:

– If you press the right arrow, the Mario sprite moves to the right while changing his costume to show that he is starting to walk and sends a message to scroll the two background sprites:

Here is the final program for the Mario sprite:

Creating the first background sprite:

The background sprite should scroll when the Mario sprite is running.

1) Go to Upload Sprite .

2) Choose the sprite below

3) Background sprite program:

– At the beginning, we put the sprite in the background and place it in the initial position:

– If the Background sprite receives a message from the Mario sprite, it scrolls left:

Here is the final program for the background sprite:

Creation of the obstacle sprite:

The obstacle sprite scrolls throughout the scene in a continuous fashion.

1) Go to import sprite to add the Back sprite.

2) Choose the obstacle sprite containing two costumes:

3) Obstacle sprite program:

– At first, we put the obstacle sprite in the background and place it in the initial position:

– The obstacle sprite is scrolled horizontally in the scene. If he reaches the edge of the stage, he changes the costume and positions himself in the initial position.

Here is the final program for the obstacle sprite:

Also, children code the same game on another platform called Code.Org

Below is the snapshot of Mario game written by the same UnicMinds student on the Code.org Game Lab platform

Join our block coding and scratch coding classes to learn coding and have fun making games, apps and websites. Learn more.

Click here to take a free trial class today.

Hope this is useful ,thank you.

Scratch Coding Classes for Kids
Scratch Coding Classes for Kids

You may like to read:

6 Amazing Games 6 Year Olds Have Built

Binary Trees of Computer-Science – A bit twisted!

Teaching Game Development to Kids

8 Types of Intelligence

BOOK A FREE TRIAL