Welcome to our fifth and final blogpost from our National Coding Week special. If you’ve missed any of the other four, or want to find our more about what we’re doing, and why we’re doing it, then head over here to find out more.
This final post, as mentioned previously, is all about playing a game. We are going to combine together each of our previous elements, and turn them into something playable! To recap, we’ve got the Colour Picker, the Dice, the Letter Spinner and the Countdown Timer.
Before we get into the fundamentals of the game, we are going to combine together each of our individual elements, so that at the push of a button, our game runs! If you remember, each of our projects shared the fact that they were started at the push of a button, or when the I/O pad was HI. By tweaking each project to turn an I/O pad, connected to another Crumble, to HI at the right moment, we can cause a chain reaction! To get a better sense of what is going on programmatically, lets look at our new Colour Picker code.
Notice the addition at the end of the code. We’ve set C HI, which is connected to A on the next Crumble (running the Dice program). We then wait 100ms and set it LO again.
We’ve changed each program (apart from the Countdown Timer) so that it runs the additional code snippet after it’s finished it’s main purpose. We have changed the Countdown timer code so that it doesn’t wait for another input to reset the servo, rather it resets itself after a few seconds.
To get this to work correctly, we need to have common grounds (-ve). The easiest way to do this, like we have, is to use a single power supply.
Lets look at the chain reaction in action!
Now we come to the game, which is played as follows. The aim is to come up with as many words as you can, which are as long as the number on the dice, within the time limit (one and two may be tricky, so you could remove them). The colour at the beginning relates to a bit of a forfeit which takes place during the round. These are as follows:
- Red – Scattergories mode. If any of your words are the same as anyone else’s, they don’t count for anyone! You need to be unique to win.
- Green – Hand switch. Swap your usual writing hand, for your non-dominant one.
- Blue – Shout it out. Every time you write down a word, you have to shout it out.
- Yellow – Normal. No bizarre rules, just write down as many words as you can.
Let’s look at an example.
Here we’ve ended up with green, five and G. This means that we need to write as many five letter words as we can, that start with the letter G, in 30s. But we have to do it with our non-dominant hand, so in my case I would swap to my left hand to write with.
And there we have our game ready to play! Clearly you aren’t limited to this version of the game. There’s a plethora of possibilities out there using these examples or combinations of your own.