Thursday, 12 May 2016

BBC Micro:Bit Higher Or Lower Game

Higher Or Lower Game


I'm becoming a firm believer in the power of children and their wishes, this device is giving me lots of opportunity to allow the children to dictate where the projects go.


So far, we have made dice and been introduced to them... the next project is a game that was proposed by a number of children on the back of the dice project.


So how to make a higher or lower game... (Again, I have tried to get the children to think about the instructions as much as possible to give them control over even the finest elements of the game. They may come up with more effective improvements.)


Now we needed a way to actually work the controls using the Micro:Bit. We could make our prediction, reset the device and press the two buttons, but this is not a game like that.

To do this, we need a button press event and to create a new random number to compare it against.

The comparison stage took a little while to explain to the children. This is because it used a logical argument about 'Greater Than' and 'Less Than'.

The basic test is, if we press the A button, we are choosing lower. So we want our 'New' number to be lower than the original. If we press B then we are calling higher...

If we are correct, then we want to replace the number being shown on the screen so that we can continue playing...

This program works, but the current result is that, if I choose higher and the random number ISNT actually higher, nothing really happens. I have to press the button a few times and I WILL get a higher number eventually. So we quickly added in a statement to allow us to lose the game.

We are now very close to the completed article. This final version requires a few tweaks. The children wanted to add a score which was easy enough. I had to insist on adding a few other changes, because they witnessed that the screen never actually stopped showing the number stored in 'Random Number'.

So instead of a While True loop, we had to have a variable which stored the value of true.



2 comments:

  1. no to confusing for me

    ReplyDelete
  2. Samtgemeinde Sögel A blog like yours should be earning much money from adsense..-.,”

    ReplyDelete