Bird
We are going to make a the Flappy bird game on microbit.
Supplies
a Microbit + a usb cable to connect to ur computer.
and you will need the microbit editor online to make the code.
Add a Bird
First, add a sprite for the bird in the game and make it blink.
Make the Bird Fly
In advance you make the code for the game actions, firstly add controls so that it can move around.
Control the bird by pressing the A button to go up or the B button to go down.
Generating Obstacles
We're going to create barriers at random. All impediments will be kept within the array.
Every obstacle has a small hole through which the bird can fly. Make a "obstacle" line that will hold all of the obstacle sprites.
Make Obstacles Move
Using a "for element loop" (revisit through the obstacles array), access each obstacle and decrease the obstacle X coordinate by one. Rename the "value" block to "obstacle" by right-clicking it and moving it on top of "sprite" in the "change x" block.
Make Obstacles Dissappear
After reaching the leftmost corner, make obstacles disappear. Iterate via all obstacles and delete all sprites with its a X coordinate = 0 from the obstacles array.
Generate More Obstacles
Currently only one vertical hurdle is created by our code. To keep generating new obstacles, we must add code to the endless loop for obstacle generation.
As a result, there are numerous moving objects on the screen right now. Create certain spacing between barriers formed. For now, we'll construct a ticks variable to track how many iterations the endless loop has gone through, and only create obstacles if ticks is divisible by 3.
Game Over
When the bird is struck by an impediment, nothing happens. This can be fixed by iterating over the obstacles array and looking for any sprite coordinates that match the bird coordinate.
If you want you can add music to, to your game.
The Final Code
If you did everything right you should have this.
A movie of how it works.