Learn Scratch by Reading and Analyzing Others’ Code – Super Mario Part 1

If you learn Scratch coding for a period of time and become familiar with basic functionalities of building blocks, you might challenge yourself to learn more advanced skills. A good method is to learn others’ work and analyze them thoroughly. After you understand each code segment of an excellent code work, you will learn new skills and apply them in your own project development. Believe me!

Let me give you an example on the analysis of my favorite project New Super Mario Bros. You could find the original project URL at https://scratch.mit.edu/projects/303550038. It is created by Brad-Games. Thanks for the sharing. 🙂

Level 0
Level 1

The project is still under development. It is based on the very popular classical Super Mario game. The author adapted it to Scratch platform by adding his own innovative ideas. Since there are many highlights in terms of code structure and game design, I will explain the key points in two posts.

In this post, I will explain the animation of title page, and how those moving background, fixed or moving objects are created. In the next post, I will introduce how the author create a vivid Super Mario Bros.

Title Page Design

Watching the above video clip, you will notice that the title “Super Mario Bros.” falls from the upside of stage with a bouncing effect. The effect is implemented in the following code:

Code for Stage

The author did not put much code in stage sprite, but it has implemented a super important function in this project. As we could see in the following code segment, the stage sprite will broadcast message “GTC” continuously since the author wraps this message in a forever block. It is just like a clock, reminding several sprites – moving backdrop, fixed and moving object – what they should do in real time.

The Moving Backdrop

To create real moving effect, the backdrop should scroll in a opposite direction of Mario’s movement. In this way, Mario the key character could always be kept in the center of the stage, but in the eye of the player, it is just walking forward.

The Ground Objects

Just now, I explained how the moving backdrop is created. It is not enough to just have the plain backdrop. The super Mario will run over the grassland, hip onto the stone platform or jump over the river alone the way. Let’s take a look at how the author builds the landscape shown below.

The method is the same as that for the moving backdrop. The author combines 11 costumes together to form a rolling landscape. The author uses the code “Create clone of myself” and “next costume” to make every clone have different appearance. Cool! the idea is great. We could use this idea in our own game design.

Code for the Fixed Objects

We like playing Super Mario, because it is just like an exciting adventure and on the way to destination, Mario might encounter both good and bad stuff. He could collect gold coins, eat mushroom to grow bigger and more powerful, or encounter the evil monsters and lose its life. Here again the author uses cloned object and message GTC to make those objects positioned correctly.

Like creating moving background, the author creates solid objects by “create clone of myself” and choose the corresponding costume. In the current version, there are only two types of solid objects, e.g. Itembox and Falling Platform.

Code for Moving Objects

The method for creating moving objects is similar to that for fixed objects. The difference is that you also need to design the motion of moving objects. Here we take the example of Piranha Plant.

Piranha Plant

The author uses the parallelized coding in many places. For example, he uses three same event block – “When I start as a clone” – to write the behavior of Piranha Plant. One code segment addresses the movement of the plant, the other addresses the change of costume, and the third one checks if the plant touches Super Mario. In this way, Piranha Plant could move, change gesture and sense the touching at almost the same time. The code could have a fast response.

This post is done till now. In the next post, I will explain how the author designs Super Mario’s behavior and use transparent hitbox and sensors. Cool design and keep tuned!

4 thoughts on “Learn Scratch by Reading and Analyzing Others’ Code – Super Mario Part 1

  1. The Coding Fun

    depending on your subscription package, your backup plan could be different, but there are always copied/historical versions of your posts and pages. So it is safe if you just write posts and publish your content. If you want to use membership or online store, that is another topic. You need to use plug-ins. Personally, I am not much confident about that.

    Like

  2. Good day! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?|

    Like

  3. Pingback: Let's Learn Coding Skills through Analyzing Others' Code – Analysis of Scratch Tetris – Coding Courses Designed for Kids

  4. Pingback: Let’s Learn Scratch Through Others’ Project – A Sample Project Part I – Coding Courses Designed for Kids

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.