🎄Merry Christmas🎄Coolest Christmas Gift Received Ever!
🌟All products' price reduced by 15% off
🎁Hot-Selling Items: Buy 10 Get 1 Free

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 [email protected].

Leave a Reply

Frame 422188
Meet ELECFREAKS at BETT 2025!
Frame 422521
Our New Distributor——BERRYBASE
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Frame 422188
Meet ELECFREAKS at BETT 2025!
Frame 422521
Our New Distributor——BERRYBASE
images
How to make a counter with micro:bit?
Monthly Archive