You hit the cleaning robot with the adjustable wrench for 7 damage!

This month was a journey into strange and uncharted territory for me. Instead of making tools to make a game I hadn’t made yet, I actually made a small quantity of game. Something playable. And it only took me two years to get this far.

combat

The little bit of game I’ve made is the combat system, or at least, the bare bones of it. The finished thing will be big and complicated. My principle, right from the start of this whole project, was that even though the combat was going to be text-based it had to be varied, enjoyable and polished. It had to be more than just the old Roguelike thing of “The orc hits you for 7 points of damage! You hit the orc for 3 points of damage!” And I mean no disrespect: even that stuff takes a lot of work to get right, as I was soon to learn.

I found myself following the trail a thousand pen-and-pencil RPG developers had trod before me, battling the same demons they had fought. Do you want everything in a round of combat to happen at once? No! If the player and the monster are down to their last hitpoint each, you want it all to hang on who strikes first. There has to be sequence, but blended with a pulse-quickening element of chance. That is precisely why village halls and teenage bedrooms have echoed down the years to the immortal cry of “Roll for initiative!” But code rolling for initiative into a videogame, and that has ramifications: you have to be able to sort your combatants so that they act in the right order, for one thing. Suddenly my programming language, Tig, needed a bubblesort facility. You need to know if an enemy is active or not, or off-balance or not, so now I needed binary flags.

This was actually a lot of fun. I’ve discovered that now I’ve coded a working compilable language, adding new features to it is actually pretty easy. And I can add whatever I want, because it’s my language. All those little things Bjarne Stroustrup didn’t put into C++ because he didn’t know people would one day need it to code videogames, I can put into Tig. And the really cool bit is that once they’re there, they’re there for good, making other tasks easier as you get to them.

The biggest challenge has turned out to be trying to get the code to describe the action in good English. There’s a reason most text games say things like “The cleaning robot is attacking you! The servobot is attacking you!”, rather than “The cleaning robot and servobot are attacking you!” and that’s because it’s a lot easier. Sure, you can code a little loop that lists the names of all the robots in the attack, but what if there are ever three robots? Now you want to say “The x robot, the y robot and the z robot are attacking you!” The first two terms have to be separated by a comma, the last one by an ‘and’. Now your loop has a messy ‘if… else… ‘ statement nesting in it. Soon, they’re all over your code, like hideous syntactical tumours. Computers don’t do grammar, you have to teach them all these little rules.

Anyway, it’s a work very much in progress, as that screenshot shows. But I’m pleased to have set off on the adventure.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s