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:
Next, we continue to add code to it.
Create a new ball sprite, you can choose any ball you like.
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.
Add the following code to the ball sprite:
This code creates a new clone of the ball sprite every three seconds. Each new clone moves along the top platform and then drops.
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.
After adding, the code for your sprite clone should look like this:
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:
Finally, add a code block to your character sprite so that it returns to the starting position when it receives the finish message:
Test your code. Check if the character returns to the starting position after hitting the ball.
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 firstname.lastname@example.org.
Share this post
About the Author
ELECFREAKS focuses on microbit and publishes interesting articles
- Micro bit supplier
- Wholesale Suppliers
- Micro bit tutorial
- Micro bit classroom pack
- Mcorbit Environment Monitoring
- TPBot car
- Micro:bit car
- AI Lens
- Micor:bit AI Lens
- Micro:bit LEDs
- BBC micro:bit
- Micro:bit Manipulator
- Wukong board
- Micro:bit Motorcycle
- Nezha breakout
- Micro:bit DIY
- 360° servos
- AI Lens
- Retro Arcade
- Microbit programming
- Do your:bit
- Rainbow LED Ring
- Wonder Building Kit
- Laser Engraver Tutorial