MVCode Dash 2

Planning
Step 1
In this lesson, we will be making the ground move and the player jumping
23
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

20
Step 4
Add this code to make the Ground clones move by speed forever
21
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
22
Check Your Work
Step 6
The ground should be moving when we play the game
Information
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

25
Challenge
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

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

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

28
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!

29
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

Account

MVCode Clubs

Created By

Missing tiny aaronjau101

Course:

MVCode Dash

Access Level

premium

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