Sign in to follow this  
Souljah

Progress in a text based game...

Recommended Posts

Hi I've been given the task of making a text based game much like the world of zuul game (1970's) if anyone remembers. If anyone knows about this it will be alot easier. But the game is basically just about navigating through a series of rooms. What I want to ask is, If I want to make the game sort of story based, with characters and interacting items, what is the best approach? When I say story based, I mean that after certain goals and criteria are met then the game appears to 'progress'. For instance I have a dialog that prints to the terminal upon entry to a new room. What I'd like to do is have the standard dialog for a room change if an action has been completed. To show some type of difference in status. ATM I'm thinking of just having boolean expressions to define when things change (e.g. when x = true then the dialog for RoomA is "blah blah", otherwise it is "abc" or something) Is this a good way to do it? Or should I have a numerical representation of the state of the game (Using a load of if statements referring to a 'state' variable to determine which dialog to print to the terminal? This is using JAVA btw... Thanks for any help.

Share this post


Link to post
Share on other sites
Just use variables for your plot points and then check against them before acting. If you plot is completely linear you can do this even easier by just using one variable and incremting it... like

int nPlot = 0; (0 means nothing is done)

When nPlot == 3 You've completed the third step in the story, and you can know in your code that the user has 1)locked himself out of his apartment, 2) wandrerd around the back, and 3) built something to climb up to his window...

Share this post


Link to post
Share on other sites
Some time ago i found a complete serie of video tutorial (you can see the ide and the guy has microphone explaining what he is doing) :
http://www.rdxgames.net/projects/wrathlands/index.html
Be careful however, take it with a grain of salt because it's far from perfect:
It's relatively slow and boring (it's not just key point but you see him code each and every single line of code).
He seems to do things on the fly without planning and the code is sometime not really good (an || doesn't work so i'll try with an &&, woops doesn't work either...).
I don't like the way he structure his code (i need an Inn so i'll throw an Inn function...), but would have done it in an object oriented language so...

Apart from that it's a rather funny and unique tutorial which might interest

Share this post


Link to post
Share on other sites
From an artists point of view (hey, perhaps text is also an art? ;)), it works much easier to have some sort of script parser that allows the artist to create and change his levels (or story elements in this case) without the need for a recompile.

A way to do this could be to have each story element as an object, with various options like a state, a name, a text body, options for the player and their actions (assuming the game allows the player to pick one from various options, as in 1) go to room A, 2) pick up item B).
Another type of object would be the rooms, that are linked to the above mentioned story objects. However, one of the possible actions of a story element is changing the object a room refers to. This means that, when you're in room A you trigger text object 1 and pick the 'pickup item' choice, that choice performs an action that changes room A's text object to # 2, which has a slightly different text and all but the 'pickup item' choices.
Or, as an alternative, you could alter other sorts of variabeles and have a room check for these in order to decide it's text object.

Of course, there could be better or smarter ways, depending on the complexity of the scenes and the amount of actions, but this should give you an idea.


As for checking states, maybe you've heard of the state machine design pattern. Basically it's having a state class instance that handles a certain action, and when a different action needs to be done you simply change this pointer to refer to another state class with the desired functionality. You may want to read up on it. If not directly usefull, it's still an interesting approach.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this