Discuss Scratch

Miniman637
Scratcher
43 posts

How to make a Mario Game

My name is Miniman637 and this is a tutorial!

In this tutorial, we will learn how to make a Super Mario game. Note: Bookmark this tab so you can follow my tutorial!
We will start with setting up the sprites, and variables. You'll need the Player sprite, which is Mario. And you'll need to set up assets, too. Entities, blocks, enemies, all we need!

Miniman637
Scratcher
43 posts

How to make a Mario Game

You want a thumbnail and a play button. The game needs to start when you click it. I also wanna add some cool size-changing when touching mouse-pointer or not.

when green flag clicked
go to x: (0) y: (-81)
forever
set [brightness v] effect to (<touching [mouse pointer v] ?> * (10))
if <(distance to [mouse-pointer v]) < [50]> then
change size by (((190) - (size)) / (5))
if <<touching [mouse-pointer v] ?> and <mouse down?>> then
change size by (((150) - (size)) / (5))
wait until <not <mouse down?>
play sound [Finger Snap v]
broadcast [start v]
end

else
change size by (((150) - (size)) / (5))
end
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

Now let's go ahead to the actual game. Mario will have to start at the left of the screen. Then he'll have to move with the arrow keys. When he hits the center, he'll stop and the level will have to scroll.

when I receive [start level v]
go to x: (-240) y: (0)
set [scrollx v] to [0]
if <(x position) > [0]> then
change [scrollx v] by (xv)
else
change x by (xv)
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

We have to add touching sensors to Mario. So they need to follow Mario, and detect Mario to stop when they detect it. There needs a top, bottom, right, and a left.
Here's the right one:

when green flag clicked
forever
go to x: (([x position v] of [Player v]) + (10)) y: ([y position v] of [Mario v])
end

when green flag clicked
forever
if <touching [Level v] ?> then
set [rightsense v] to [1]
else
set [rightsense v] to [0]
end
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

Now here's the left one:

when green flag clicked
forever
go to x: (([x position v] of [Player v]) - (10)) y: ([y position v] of [Mario v])
end

when green flag clicked
forever
if <touching [Level v] ?> then
set [leftsense v] to [1]
else
set [leftsense v] to [0]
end
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

Now here's the top one:

when green flag clicked
forever
go to x: ([x position v] of [Player v]) y: (([y position v] of [Player v]) + (10))
end

when green flag clicked
forever
if <touching [Level v] ?> then
set [topsense v] to [1]
else
set [topsense v] to [0]
end
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

Last but not least, the bottom one:

when green flag clicked
forever
go to x: ([x position v] of [Player v]) y: (([y position v] of [Player v]) - (20))
end

when green flag clicked
forever
if <touching [Level v] ?> then
set [downsense v] to [1]
else
set [downsense v] to [0]
end
end
Miniman637
Scratcher
43 posts

How to make a Mario Game

Now we are actually going to make Mario move with the arrows! This is my favorite part, by the way. Is it yours, too? OK, let's not get too carried away, we've got scratching to do.

when green flag clicked
forever
if <key [right arrow v] pressed?> then
point in direction (90 v)
if <(rightsense) = [0]> then
set [xv v] to [8]
else
set [xv v] to [0]
end
end
end


when green flag clicked
forever
if <key [left arrow v] pressed?> then
point in direction (-90 v)
if <(leftsense) = [0]> then
set [xv v] to [-8]
else
set [xv v] to [0]
end
end
end


when green flag clicked
forever
if <<key [up arrow v] pressed?> and <(downsense) = [0]>> then
play sound [Jump v]
if <(topsense) = [0]> then
set [yv v] to [11]
end
else
if <(downsense) = [0]> then
set [yv v] to [0]
end
change y by (yv)
end
end

Last edited by Miniman637 (June 13, 2024 04:24:14)

Paddle2See
Scratch Team
1000+ posts

How to make a Mario Game

Hello! It's great that you want to help out other Scratchers. However, I think we have enough guides in the forums at the moment. Please feel free to welcome new Scratchers on the group welcoming topic or on individual topics created by New Scratchers.

Other places that can always use more helpful Scratchers like you, are the "Help With Scripts“ and ”Questions About Scratch" areas - please use them as designed, by responding to topics created by folks with problems to solve

Finally, a really good place for Scratch guides is the Scratch Wiki - check it out and see if it's something you might like to work on. They have a number of guides - and great organization.

Powered by DjangoBB