I may have gone a bit nuts and hammered out a fairly fully-featured version of my game in Scratch.

First off I built up the battle mechanic so the two combatants would take turns. At the moment QR1 always goes first but it would actually be very easy to implement a system to flip a coin.

When damage is inflicted the participants audibly complain (utilising my remarkable vocal talents…). When a critical fail is rolled they moan about that too. Such things may seem needless but I originally implemented them to facilitate testing. Watching the output log variable the whole time is a little tricky as it sometimes changes quite quickly. Audio cues quickly report whether something worked or not even if they do introduce another (small) point of failure.

Initially input was in values between 0 and 255. Late in the evening I decided that figuring those out from hex was too much hassle.

So, of course, I went overboard and coded up a little hex converter. The explanations I found for how to do it were amazingly complicated. I started coding, gave up, and tried again. Eventually I found an explanation from Cisco of all places that explained it.

Basically:

F = (F * 1)

FF = (F * 16) + (F * 1)

FFF = (F*16*16) + (F * 16) + (F * 1)

My values would always be two characters long so it was then just a matter of coding a calculator that would step in and convert numbers when they were provided before handing back control:

scratch_hex_conversion

It’s long but not all that complicated really.

That meant that I’d need to input the raw hex values. Pretty good.

That was hassle though so I decided to push things a little further. You know what they say – if a job’s worth doing it’s worth writing a script to do it for you!

So after a bit of jiggery pokery and some differences between Scratch 1.4 and the (currently) web-based Scratch 2.0 I had two versions that both worked. Convert the QR code at ZXing and paste the output as input. My code identifies the required values and converts them to stats automatically.

Sorted.

0 responses to "I had to fork my codebase today. Can I legitimately call myself a geek now?"

Leave a Reply