# Ecode Dodgeball (II)

Hello, following the ecode Dodgeball (I) last week, in this project I am going to extend it with more functions---ladders climbing and jumping, in this way the sprite could move on the map as you wish.

See the program here:

In fact, if you want to achieve the function of climbing the pink ladder, you need to move the character sprite up a few steps on the stage when the up arrow is pressed and the character sprite just touches the correct color.

Add the following blocks in the program as the picture displays, then add the y (vertical) coordinate.

Test your code to see if the sprite could climb and go to the destination.

Let’s make the character's movement more realistic: add gravity to the game and make the character have the ability to jump. In the game, move your character to leave the platform. Do you see that it can go to a blank place?

To solve this problem, you need to add gravity to the game and create a new variable named gravity (you can hide this variable in the stage as needed.)

Add the following blocks that set gravity to a negative number, and use the value of gravity to repeatedly change the y coordinate of the character. Gravity should not cause the sprite to pass through the platform or ladder! You need to add an if block to your code to allow gravity to work only when the character is in the air. The gravity code should look like this:

Test the game again to see if gravity is working properly now. When the character sprite touches the platform or ladder, will it stop falling? Can you make the character walk out of the edge of the platform and fall to the platform below?

Now add code to make your character jump up when the player presses the space bar. A very simple method is to move the character up for a few times. Since gravity keeps pushing your character down by 4 pixels, you need to choose a number greater than 4 among the blocks that increase the y coordinate. Change the number until you are satisfied with the height of the character's jump. In order to make the jump look smoother, you need to adjust the rise of the character sprite to be smaller and smaller, until it no longer rises. We need to create a new variable named jump height. Similarly, you can hide this variable as needed. The jump code should look like this:

Even if the character is already in midair, as long as the player continues to press the space bar, the character will continuously jump upwards. If you keep holding down the space bar, you will see this phenomenon.

Can you change the jumping code of the sprite so that the character can only jump when it touches the blue platform? Looking forward to your challenge!

Software : ecode(www.ecode.cn)