Ecode Dodgeball (3)

ecode Dodgeball (3)

Hi, today we are going to add the last "dodge ball function" to the ecode Dodgeball game. Your character can now move and jump. It's time to add some dodge balls to make it more difficult.

Let's take a look at all the code after we wrote it last time:

Dodgeball

Next, we continue to add code to it.

Create a new ball sprite, you can choose any ball you like.

Dodgeball

Adjust the size of the spherical sprite so that the character can skip it. Try to make the character jump over the ball to test whether the ball is the right size.

Dodgeball

Add the following code to the ball sprite:

Dodgeball

This code creates a new clone of the ball sprite every three seconds. Each new clone moves along the top platform and then drops.

Dodgeball

Add more code to your sprite so that its clone can move on all three platforms.

Repeat the code block to move the sprite clone on the first platform. You need to change x, y, and the number of repetitions so that the clone can move correctly on the platform.

Here are the code blocks you need,make sure to add them in the correct order.

Dodgeball

After adding, the code for your sprite clone should look like this:

Dodgeball

If your character is hit by the ball, add some code blocks to broadcast (send) the message! Add the following code to the sprite character:

Dodgeball

Finally, add a code block to your character sprite so that it returns to the starting position when it receives the finish message:

Dodgeball

Test your code. Check if the character returns to the starting position after hitting the ball.

Dodgeball

The dodgeballs look all the same, and will always appear every three seconds. Can you add code to the game to make the ball be able to do these?

1. Do not look the same.

2. How long does it take for a random to appear?

3. Is the size of the ball a random value?

If you have any ideas or opinions, please feel free to contact us via services@elecfreaks.com.