Ghost Town: It all falls into place

After making some good progress the other day with walking around and going through doors, I was a bit anxious about how to integrate object manipulation to the game. I thought about having a config file, describing each object and the consequences when trying to pick it up, like

gloves {position …, replace by …, items that need to be in inventory to pickup…, die sequence…} 

and so on. Then I thought about how to read in the configs and run them through each time an object it touched.

Today I thought “heck, why not start simple and have it all right where it is needed: in a simple script?” And due to the beauty of how the whole game is read in and displayed, the idea worked right out of the box.

This is the (still quick and dirty, but working) example code for picking up the gloves in room one:

Are we in Room 1?
Is “a9″ (the hexcode for the gloves) where the player wants to go?
take the glove
delete the gloves from the game world

That’s it. It can even be optimized (and needs to), especially when it comes to inventory handling. But anyway, it took me 10 minutes to define the first three rooms, which is nothing short of exciting for me. 

Edit: quickly added proper inventory handling, so the glove example now comes down to this:

So much fun!

Leave a Reply

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