Textual objectification

When a developer doesn’t update his devblog for a whole nine months but keeps working on his game all that time, you just know the end result is going to be something amazing, right? Well hold onto your hats – why you have multiple hats I don’t know – because here is the result of all my secret labour. Right here, right now:

 

Yeah.

You can probably see why I didn’t bother updating this blog now. I’ve been working on Tig, my compiled programming language, all this time, and programming languages just aren’t that exciting to blog about. Nor do they make for exciting videos. I didn’t even realise how amazing I was being until one day, out of curiosity, I turned on my text editor’s code-styling option – the setting that colourises for clarity. And wham! My bland, middle-class-white-boy code turned into this:

TigCode

I know! It’s like something you see scrolling up someone’s monitor in Mr Robot, right?

That was when it hit me: oh my God I’ve actually created a programming language.

That’s not C++ you’re looking at there, or whatever bobbins GameMaker uses. That’s Tig. That stuff is read by my compiler, turned into machine-independent bytecode, then run in-game to produce the video you saw above. Codewise, I’ve done something pretty incredible. For an English Lit student.

Yet when people ask me how the game’s going and I try to explain Tig to them, a sort of glazed, polite-but-where’s-nearest-exit look appears in their eyes. I can’t really blame them. Programming is hard and boring to explain, programming compiled programming languages doubly so. Indulge me in this quick BBC Bitesize summary and we’ll never speak of it again.

It’s an Object-Oriented Programming language
OOPs tie together related code and data in virtual objects that message each other. This is very handy for game design, where you’re basically making a world full of virtual objects that interact. Such as crates. In Tig, you make a crate by writing:

CGameObj crate has name “crate”, description “A standard wooden crate for use in games.”,
weight = 10;

This says “make an object derived from CGameObj and give it a property called ‘name’ set to the text ‘crate’, a property called ‘description’ set to the text ‘A standard wooden crate…’ and a property called ‘weight’ set to the integer 10. CGameObj is another, much more complicated Tig object that handles all the default game code for in-game items, such as printing the description text when you examine them. And this is the clever bit: because our crate is derived from CGameObj it will inherit all that functionality automatically. You don’t have to write another word.

Suppose you want the crate to shatter when it’s hit. The game calls an item’s ‘onHit’ property if it receives damage, but the CGameObj default onHit response is to do nothing. So we write this:

CShatterable has onHit() { print “The ” + name + ” shatters into pieces!”;
destroy self; };

Now if you derive our crate from CShatterable as well as from CGameObj, CShatterable will hijack onHit. The result: a fragile box that destroys itself on receiving damage, and tells the player this has happened. But the really clever bit is that now you can attach CShatterable to any item to get the same effect, whether it’s a Ming vase or a mastodon.

Want an exploding crate or mastodon? Write this:

CExplosive has onHit() { print “The ” + name + ” explodes in a fireball!”;
destroy self;
player.onHit(100); };

Notice how the exploding object will now use the player’s bespoke onHit property to give them splash damage.

Once you’ve coded a few useful template objects, you can create in-game items with quite complicated behaviour simply by combining them. This should pay big dividends later in the development cycle.

It creates its own hypertext
Interactive fiction is not cool. One of the reasons for this is that in an age of virtual-reality spaceships, you still have to laboriously type what you want to do in an IF game. I’ve tried to offset this a little by using hypertext, so you don’t type, you just click.

The clever bit isn’t the hypertext. The clever bit is that Tig will mostly hyper that text for you. If you write a room description that includes the text “…there is a narrow passage to the east”, Tig will understand that ‘east’ is a direction, and if you can go east from this room it will turn the word ‘east’ in that sentence into hypertext that will take you east when you click on it. If you write a room description that says “an old piano moulders in the corner” and you’ve coded a complicated piano for the player to interact with, Tig knows to make the word ‘piano’ hypertext and connect it to your piano code. Most of the hypertext you can see in that video – just about – is being created and removed on the fly by Tig.

So there you go. All this took a long time and an awful lot of work. One day it may yet end up in an actual game. Until then, I’ll try to code something less geeky for the next blog entry. See you in another nine months!

 

 

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