MVCode Dash 2

Step 1
In this lesson, we will be making the ground move and the player jumping
Step 2
Start by creating a variable named "Speed"

This will technically be the player's speed, but it will in fact be moving everything except the player

17 18
Step 3
Add code to set the Speed variable to -10 when the green flag is pressed

I will be adding this code to my Stage, but it doesn't really matter where the code is placed

Step 4
Add this code to make the Ground clones move by speed forever
Step 5
Now we will make the Ground spawn clones side by side and delete the clones that reach the left edge of the screen
Check Your Work
Step 6
The ground should be moving when we play the game
Step 7
To get the player jumping, we will need two variables: "Y Speed" and "Gravity"

Y Speed will control the player moving up and down, while Gravity will always be trying to pull the player back down to the Ground

Step 8
On your own, add two variables named "Y Speed" and "Gravity"

Hint: Look at Step 2 to see how we created a new variable for Speed

Step 9
Now make the two variables start off as these values
Step 10
Now add this code to the player

This will make the player fall with gravity and stop when it hits the ground

Step 11
To test gravity we will need to jump when the space bar is pressed and the player is on the ground

The player will also be doing a front flip!

Check Your Work
Step 12
Check if you're player jumps when space bar is pressed

The lesson is now complete!

In the next part, we will making the triangle hazards move and cause the game to end.

MVCode Dash 2 Info


MVCode Clubs

Created By

Missing tiny aaronjau101


MVCode Dash

Access Level


For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach