"It’s Here! The BFCM Sale of the Year – Grab Your Favorites!"

Catch the “Apples”

Hello, this week I am going to make a catching apples game through a micro:bit. Let’s see how it works below:

Catch the Apples

Drag the sprite bricks in the MakeCode drawer.

Catch the Apples

Create two sprites(One as the falling apple, another as the basket to catch the apples)

Catch the Apples

In on start brick, set the basket at the bottom side by fixing Y as 4 and X at a random value, here we assign 0 to it. And we set the apple at the top side by fixing Y as 0 and X at a random value (here we assign 0 to X).

Catch the Apples

Movement of the basket: Control it via the buttons and set them as below:

Catch the Apples

Apple’s movement: After powering on, it moves down from the position (0,0). During this process, only the Y coordinate changes, while the X coordinate maintains the original value. To fall to the bottom, it needs to change to 1, 2, 3 and 4(four times in total), thus we use repeated execution in four times and increase its Y coordinate by 1. In this way, an apple lands off. After one finished progress, another needs to follow, set the Y coordinate of this sprite to 0 (back to the top), and take a random number from 0 to 4 for the X coordinate. In this way, when the apple returns to the top, it locates randomly and is displayed on the top 5 LED lights.

Catch the Apples

By judging whether the two sprites are in contact, you would know if the apple is catched(Here I give a sound feedback once the apple gets catched by the basket).

Catch the Apples

Completed program:

Catch the Apples

https://makecode.microbit.org/_VLP1ijMebJuF

If you have any ideas or opinions, please feel free to contact us via [email protected].

Leave a Reply

images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
images
Children’s Programming Education is the Future Trend
images
Technical verification! Nezha series products can complete WRO competition tasks
images
Let's take part in the Ceremony of the New Factory of ELECFREAKS together!
images
Bluetooth Bee(HC-05 and HC-06) User Guide
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Monthly Archive