Learn Scratch Lesson 15
Learn Scratch Lesson 15
In this lesson, we will wrap up the Mini Mario game by making it scroll, among other
things. Also, please go to http://shallwelearn.com to download
MiniMarioLesson13.sb from Scratch Programming Lesson 13.
This is the snapshot of the sprite list when the project is opened.
Create a global variable called scroll to represent the amount of scrolling. When
Mario moves to the right, the scrolling amount decreases, and when it moves to the
left, the scrolling amount increases. If you are unfamiliar of how scrolling works in
Scratch or in general, please refer to Shall We Learn Scratch Programming Lesson 14.
I am going to split Platform sprite into two sprites: Platform0 and Platform1.
I will line these two platform sprites side-by-side. When the game starts, Platform0 is
located at x = 0 or 0 * the stage width (=480). Platform1 is at x = 480 or 1 * the stage
width.
Then make a copy of Platform0 and name the copy as Platform1. Delete costume
Level2 from Platform0 and rename costume Level1 to Level and delete costume
Level1 from Platform1 and rename costume Level2 to Level.
TEST TIME: Now test the game. You can scroll but there is an obvious
problem. Both the brick and two coins keep following Mario so Mario could never
get to them. We will fix it.
To keep the brick and coins from following Mario, we need to make them scroll, just
like the platform sprites. We will copy the scripts pertaining to scrolling from
platform sprites to both Brick and Coin sprite. But we need to make two changes.
The first is to add a local variable call offset_x; this variable stores the distance from
the left boundary of the platform to the sprite.
If you would like, you can upgrade the Bullet so that you can shoot from all four
directions. Below is the updated script for the Bullet.
This concludes Lesson 15, the last lesson of Mini Mario Game series. I hope you have
enjoyed this series and leave with enough know-how to make your own platform
games!