Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a Platformer || Platformer Tutorial
- lambodhar
-
42 posts
How to make a Platformer || Platformer Tutorial
Hey There! Welcome to a Platformer Tutorial
I will be showing you how to make a Platformer with a ton of features including Enemy AI, Water, smooth movement and more!
If you use this tutorial please do credit me @lambodhar. Also, it would be great if you followed me too since I worked hard on making this tutorial
Additionally, you can have fun playing this game below:
Just click on the image to play and have fun!

Let's first start off by drawing the player!
Make a new sprite and then, draw the player as a square as depicted below

Let's now code the player
Just follow all the coding below :)
We are now done with the coding the player!
Now, let's code the level.
Make a new sprite called level.
Then make multiple costumes of different level as shown in the below picture
Each costume is a one level
Then, code the level as shown below
Now, let's make enemy AI
For this, duplicate the player sprite and then edit the enemy codes as shown below.
You can additionally, make the enemy red colour
Now, we are done with coding the enemy AI!
Now, let's code the water!
For this, make a new sprite called water and make the water level the same way you made the ground levels!
Each costume will be one level
Preferably, make the colour “blue”
Then, code the water as shown below:
AND….. You are now done!!!!
CONGRATS ON MAKING AN ADVANCED PLATFORMER!
IF YOU HAVE ANY DOUBTS, BE SURE TO COMMENT ON MY PROFILE OR YOU CAN ASK IN THIS FORUM TOPIC ITSELF!
THANKS AND BE SURE TO CREDIT ME @lambodhar IF YOU USE THIS TUTORIAL
ALSO, CONSIDER FOLLOWING ME TOO!
BYE…
I will be showing you how to make a Platformer with a ton of features including Enemy AI, Water, smooth movement and more!
If you use this tutorial please do credit me @lambodhar. Also, it would be great if you followed me too since I worked hard on making this tutorial
Additionally, you can have fun playing this game below:
Just click on the image to play and have fun!

when green flag clicked
play sound [drumroll v] until done
say [Let get started!]
Let's first start off by drawing the player!
Make a new sprite and then, draw the player as a square as depicted below

Let's now code the player
Just follow all the coding below :)
define Run Engine with speed: (speed) jump height: (jump height) Friction: (friction)
set rotation style [left-right v]
gravity::custom
if <key [right arrow v] pressed?> then
change [Speed x v] by (speed::custom)
point in direction (90)
end
if <key [left arrow v] pressed?> then
change [Speed x v] by (() - (speed::custom))
point in direction (-90)
end
set [Speed x v] to ((Speed x) * (friction::custom))
change x by (Speed x)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change x by ((Speed x) * (-1))
change y by (-5)
if <<key [up arrow v] pressed?> or <key [w v] pressed?>> then
if <(Speed x) < [0]> then
set [Speed x v] to [8]
else
set [Speed x v] to [-8]
end
set [speed Y v] to [10]
else
set [Speed x v] to [0]
end
end
end
end
end
end
end
change y by (speed Y)
if <touching [level v]?> then
change y by ((speed Y) * (-1))
set [speed Y v] to [0]
end
change y by (-1)
if <touching [water v]?> then
if <<key [up arrow v] pressed?> or <key [w v] pressed?>> then
set [speed Y v] to [3]
end
else
if <touching [level v]?> then
if <<key [up arrow v] pressed?> or <key [w v] pressed?>> then
set [speed Y v] to (jump height::custom)
end
end
end
change y by (1)
if <[237] < (x position)> then
broadcast [next level v]
broadcast [level reset v]
broadcast [setup enemies v]
broadcast [setup trampolines v]
end
if <(y position) < [-174]> then
broadcast [level reset v]
broadcast [setup enemies v]
broadcast [setup trampolines v]
end
if <touching [enemy v]?> then
set [speed Y v] to [10]
end
when @greenFlag clicked
set [level v] to [1]
broadcast [level reset v]
broadcast [setup enemies v]
broadcast [setup trampolines v]
forever
Run Engine with speed: [1] jump height: [15] Friction: [0.9]::custom
end
when I receive [level reset v]
go to x: (-192) y: (47)
set [Speed x v] to [0]
set [speed Y v] to [0]
when I receive [next level v]
change [level v] by (1)
define gravity
if <touching [water v]?> then
change [speed Y v] by (-0.3)
else
change [speed Y v] by (-1)
end
We are now done with the coding the player!
Now, let's code the level.
Make a new sprite called level.
Then make multiple costumes of different level as shown in the below picture
Each costume is a one level

Then, code the level as shown below
when @greenFlag clicked
forever
switch costume to (level)
end
Now, let's make enemy AI
For this, duplicate the player sprite and then edit the enemy codes as shown below.
You can additionally, make the enemy red colour
define Run Engine with speed: (speed) jump height: (jump height) Friction: (friction)
show
change [speed Y v] by (-1)
if <(x position) < ([x position v] of [Player v]::sensing)> then
change [Speed x v] by (speed::custom)
end
if <([x position v] of [Player v]::sensing) < (x position)> then
change [Speed x v] by (() - (speed::custom))
end
set [Speed x v] to ((Speed x) * (friction::custom))
change x by (Speed x)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change y by (1)
if <touching [level v]?> then
change x by ((Speed x) * (-1))
change y by (-5)
if <((15) + (y position)) < ([y position v] of [Player v]::sensing)> then
if <(Speed x) < [0]> then
set [Speed x v] to [8]
else
set [Speed x v] to [-8]
end
set [speed Y v] to [10]
else
set [Speed x v] to [0]
end
end
end
end
end
end
end
change y by (speed Y)
if <touching [level v]?> then
change y by ((speed Y) * (-1))
set [speed Y v] to [0]
end
change y by (-1)
if <touching [level v]?> then
if <((y position) + (15)) < ([y position v] of [Player v]::sensing)> then
set [speed Y v] to (jump height::custom)
end
end
change y by (1)
if <(y position) < [-173]> then
delete this clone
end
if <touching [Player v]?> then
if <(y position) < (([y position v] of [Player v]::sensing) + (7))> then
delete this clone
else
broadcast [level reset v]
broadcast [setup enemies v]
end
end
when I receive [level reset v]
go to x: (167) y: (47)
set [Speed x v] to [0]
set [speed Y v] to [0]
when I start as a clone
set [Speed x v] to [0]
set [speed Y v] to [0]
forever
Run Engine with speed: [.7] jump height: [15] Friction: [0.9]::custom
end
define Clone at X: (x) y: (Y)
go to x: (x::custom) y: (Y::custom)
create clone of [myself v]
This custom block helps us to place enemies.
To place your enemy, type in the X coordinate in the first blank and Y coordinate it the second blank. See below code for example on how to use the block
when I receive [setup enemies v]
if <(level) = [2]> then
Clone at X: [184] y: [88]::custom
end
if <(level) = [3]> then
Clone at X: [180] y: [-9]::custom
end
when I receive [level reset v]
delete this clone
Now, we are done with coding the enemy AI!
Now, let's code the water!
For this, make a new sprite called water and make the water level the same way you made the ground levels!
Each costume will be one level
Preferably, make the colour “blue”
Then, code the water as shown below:
when @greenFlag clicked
forever
switch costume to (level)
end
AND….. You are now done!!!!
CONGRATS ON MAKING AN ADVANCED PLATFORMER!
IF YOU HAVE ANY DOUBTS, BE SURE TO COMMENT ON MY PROFILE OR YOU CAN ASK IN THIS FORUM TOPIC ITSELF!
THANKS AND BE SURE TO CREDIT ME @lambodhar IF YOU USE THIS TUTORIAL
ALSO, CONSIDER FOLLOWING ME TOO!
BYE…
Last edited by lambodhar (Sept. 30, 2020 03:00:46)
- Cat_Dusty
-
500+ posts
How to make a Platformer || Platformer Tutorial
This isn't the right place to post this…
- lambodhar
-
42 posts
How to make a Platformer || Platformer Tutorial
Then where should this be posted? This isn't the right place to post this…
- Discussion Forums
- » Help with Scripts
-
» How to make a Platformer || Platformer Tutorial