Pick random to:
Randomly take a number in a range of numbers. In this case, we randomly
take a number from 0 to 4 for the player and the bean as its x coordinate.
Change … by:
Change the kind of number you set for a sprite. You can select what you want
to change of the sprite’s property, such as x position, y position, brightness and so on. In
here, we will this block to change the x position of bean and player.
Is touching:
Find whether the sprite is touching another sprite you set. If sprites share the
same LED then it means they are touching. There is a parameter in this block, which means
another sprite that might be touching the one you are checking. We use this block to check
whether the player picks the bean successfully.
Delete:
Delete a sprite from the game. When the player picks up the bean, we use this block
to delete the bean sprite. When the player does not pick up the bean, we use this block to
delete both of the sprites.
Chang score by:
Add more to the current score for the game. The parameter is a number
that means how much to add to the score. You can fill in positive and negative numbers.
Positive numbers add to the score, and negative numbers subtract from the score.
Game over:
End the game and show the score.
Download the program to micro:bit to see what happens.
1. Set the position of the player sprite and bean sprite and turn LED off.
2. Change the y-axis position of the bean sprite.
3. If player sprite touches bean sprite(successfully picked the bean), delete bean sprite and change
the score by 1. Then, play the melody and turn LED on. Finally, create a new bean sprite.
4. If player sprite does not pick up the bean, delete bean sprite and player sprite, play a melody
and game over.
5. Add pause block to make the beans fall a bit slower and then turn LED off.
6. When button A is pressed, if the player's x-axis position is within the matrix LED of the micro: bit
(0-4), change the x position to -1(move to the left LED).
7. When button B is pressed, if the player's x-axis position is within the matrix LED of the micro: bit
(0-4), change the x position to 1(move to the right LED).
Create sprite
: Create a new LED sprite pointing to the right. A sprite is like a little LED creature
you can tell what to do. You can tell it to move, turn, and check whether it has bumped into
another sprite. In short, you can control this sprite according to your needs. There are two
parameters in this block, “x” is the left-to-right place on the LED screen where sprite will start
out. “y” is the top-to-bottom place on the LED screen where the sprite will start out. Note: 0
and 4 mean the edges of the screen, and 2 means in the middle.
Blocks overview
50