Skip to content

Microbit Reaction Game

Note: If you want my code, contact me at hernacki.l23@questacademy.org. For some reason the file type I tried to put in the post was not working.

Game objective:

Make it through as many levels as you can without time running out.

How to play:

The screen shows “A.” When the player presses A, a symbol shows up, either a duck or a turtle. You have to press the correct pin as fast as possible. When you do, a new symbol will be shown.

There are 15 symbols per level. When the player is done with all 15, it will show them their time, and a checkmark if they made it, and an X if they did not make it.

“Well how do you make it to the next level?” you may be asking. You make it by matching all the correct symbols in less than 23 seconds. But that’s not it…

There’s a twist

With each level, the amount of time you have decreases by 2 seconds.

And in the unfortunate event that you lose…

The game will show you your time, an X and your level number. It will then restart with the A screen.

Code

As you already know, a game cannot function without code. And there are things like bugs and glitches, what if’s and all sorts of things that can go wrong. And what do you need a lot of to avoid that?

Variables

Yes, that’s right. Lots and lots of variables.

The ones that make the game function

There are essential variables in my code, like Repetition.

The repetition variable will add one to its value every time a new symbol shows. This way, when it equals 15, the game knows to stop and show the time (and level number.)

The time variable is VERY important, as it is what will get you to the next level. It keeps track of how long it takes you to get through all 15 symbols.

The non-essentials

These might not be absolutely essential, but they make the game better. “But how?” you may ask.

They do this by helping avoid bugs. For example, if you press A when you’re not supposed to, it won’t do anything. This variable is called A Available. There is also B Available (for button B) as well as Pin Available (for the pins you press to match with the symbols.)

Input blocks

In a game, one event must trigger the next. For example, if you don’t press A, the game won’t start. And if you don’t push the right pin, you won’t get a new symbol. And you won’t be able to start the next level unless button B is pressed.

This is why input blocks are so important.

For example, lots of things happen when the game is restarted or button A or B is pressed (indicating a new round.) Values for variables need to be set or reset, things need to get prepared and lots of things need to be shown on the screen. Input blocks are where the magic happens.

Some examples:

Here I will list what input blocks I put in and what their main function is.

On start

Probably the most basic coding block. In my code, it displays the letter A and sets a few variables to true/false. I think it’s pretty self-explanatory on when it happens.

On button A pressed

On button A pressed, it is mainly to set lots of variables and show you your first symbol. This is the block that will lock you out of pressing things when you’re not supposed to, and it basically sets everything in its proper place. It is also used after your game has been restarted or you lost.

On button B pressed

On button B pressed, it is essentially the same function as A. Except you only get this button when you have moved on to the next level.

On pin 1 pressed

On pin 1 pressed, this means you saw a duck. It will add things to variables, and everything is in motion. If this is your fifteenth symbol, it will show you your time, whether you passed or not (and your level number if you lost.)

On pin 2 pressed

On pin 2 pressed, it is pretty much the same as pin 1 except for the fact that it means the turtle was shown.

On button A+B pressed

This means when you push A and B simultaneously. This will reset your game.

Making the game

All right. So enough with how it works. Let’s talk about how I made it and the struggles I had with making it. And as with any project, there are easy parts and hard parts.

Easy parts

The easy parts were setting basic variables, the essentials (see the variables section.) Building it was also pretty easy, as I did it with apples instead of foil (which I’ve come to believe are more conductive.)

Hard parts

The hard parts included the non-essential variables, and also keeping track of all the variables. With so many things going on, the code became very extensive as I added more to it.

What happened to pin 0?

I was originally going to have a pin 0, but many malfunctions happened there. I did countless wire tests and tried all different conductors, but nothing seemed to work. So for the sake of time, pin 0 was removed from the code :(.

Wrapping up

I just want to say thank you if you made it all the way to the end of this long post. Happy Holidays, and see you next time!

P.S.

I was not able to include a video, so if you want to see my game in action, also contact me at the email put at the beginning of the post. Thank you!

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar