Blue overalls, red cap, and trademark moustache? Does it ring a bell? Yes, you guessed it right, we are talking about Mario, the main hero of the Mushroom Kingdom.
We are sure you have played many Super Mario games, but have you ever tried making your own Super Mario adventure?
If you haven’t, then today is the day you will embark on a fun adventure and make your version of Super Mario games!
Whether you’re a beginner or have some coding experience, this guide will walk you through creating a Super Mario game using
Scratch Programming.
As Mario would say, “Let’s-a go!”
Super Mario Games
Super Mario, otherwise known as Super Mario Bros, is a platform game series created by Nintendo. As you might know, there have been so many Super Mario games released worldwide and today your job is to recreate one of them.
First thing first, you need to decide what kind of Super Mario game you want to recreate, and which characters you want to use.
For the sake of simplicity, we are making a jumping-across platform game set in the mystical Mushroom Kingdom. This is just a basic game, which will help you create even more complex and entertaining Super Mario games in the future.
Mario will play as the main player character. (But if you like Brother Luigi more, then feel free to use him).
Choosing a Mario Sprite
Sign up on Scratch.org platform to create a new project. Click on the “Choose a Sprite” button and search for a Mario Sprite. You can draw your own or upload an image if you can't find one. Search the web for any Mario character image, and upload it on Scratch with just a few clicks.
Designing the Mushroom Kingdom
Mushroom word is so dynamic, huge and 3D, so it might be difficult to recreate the same. Instead, you can click the “Choose a Backdrop” button and select a backdrop resembling the classic Mario World. You can also draw your own.
But if you want a mushroom kingdom image as your background, search the web and import it on Scratch easily.
Adding Platforms
This is the point where you have to draw some obstacles and platforms for your Mario to climb. Either, you can use the “Paint” feature and draw out some obstacles or you can use different sprites as obstacles or platforms.
For example, you can use a “rectangular button” sprite as a platform. Or if you want to create an obstacle, then you can use stones, trees, scary animals, or even a door as an obstacle! You can find all of these by clicking on the “Choose a Sprite” button.
Program Mario’s Movements
Now that your game interface is all ready, you need to work on building logic for Mario’s movements. Mario must be able to move forward and backwards, and also jump over any obstacle or platform.
To do that, click on your Mario Sprite and add the following code blocks to make him move left and right on key presses.
when [right arrow] key pressed
change x by 10
switch costume to [walk right]
when [left arrow] key pressed
when [right arrow] key pressed
change x by 10
switch costume to [walk right]
when [left arrow] key pressed
change x by -10
switch costume to [walk left]
Great! Now, you can add the jumping code too:
when [space] key pressed
repeat 10
change y by 10
end
repeat 10
change y by -10
end
Do you think these are all the necessary movements you need? What happens when you jump? Do you jump and just stay in the air or do you land back on the ground?
What makes you land back? GRAVITY, that’s right. Similarly, you need gravity for our Mario, too, you can do that by simply adding this code block:
forever
if
> then
change y by -5
end
end
Collisions
In this step, you must ensure that Mario interacts perfectly with the obstacles and collisions. You don’t want Mario to just walk into the obstacle without any consequences or fall off from a platform, right?
To detect collision with a platform after a jump, you can add the following code block:
forever
if then
set [y v] to (y position of [platform v])
else
change y by -5 // Gravity effect
end
end
And you can add this code block, whenever Mario bumps into any obstacle:
forever
if then
// Code to handle collision, e.g., stop movement or lose a life
set [x v] to (x position of [obstacle v] - 10) // Example: move Mario back slightly
end
end
Now, if you play the game, you should be able to move around, jump over, and avoid collisions with obstacles and platforms.
Do not stop! You can let your creativity soar and add more customisation, game levels, scoring and sound effects to your game!
Adding Enemies and Coins (optional)
One thig, Super Mario games are known for is those shiny gold coins. How cool would it be if you could add those coins to your game too?
You can create coin sprites and add code to make them disappear when Mario touches them. Not only this, but you can also add a score variable to keep track of collected coins.
To add a challenging and fun twist to your game, you can aso add Mario’s enemies and make it a multiplayer game!!!
You can add sprites for enemies like Goombas or Koopa Troopas and simply program their movements and interactions with Mario.
Test and Play
Yay! You have just made your Super Mario game. Click on the green flag in the top right panel and enjoy it fully! Make sure to challenge your friends and family members to play this game that you just created!
Conclusion
Scratch is a powerful tool that allows you to unleash your creativity and learn the basics of coding in a fun and engaging way. Begin your journey in scratch programming with Codingal’s coding courses for kids, where you can unlock your full potential and learn something new at every step.
Keep experimenting, keep learning, and most importantly, have fun with your coding journey! At Codingal, we’re here to support you every step of the way. Happy coding!