Sign in to follow this  
Joppen

Planning a text adventure.

Recommended Posts

Joppen    122
Hi I am in the planning stages of text adventure and I need some help. What I want to do is a simple text adventure game that is of course playable ;) I also wanna be able to construct the levels (adventures) inside the game. For example: > make room kitchen - kitchen made and is empty. > put dishwasher. - kitchen contains dishwasher. > make connection west. - connection made in the west. Standing in empty room. and so on, hope you understand. I also wanna be able to save the adventures in a file that later can be loaded... I plan to use C++, probably console mode. What I need to know is where and how to start in a good way. Some kind of basic construction method or something like that. And any advice would be nice too. :) Many thanks for any help. Joppen

Share this post


Link to post
Share on other sites
Limitz    342
I would go for a matrix like structure. Every element in the matrix can hold any number of elements. How you store the data is up to you but i would advice using a database. You could have a table that stores roomcolumn, roomrow, element to put elements in a room.

the sql to get every element in the room would be "select element from %tablename% where roomrow=%currentrow% and roomcolumn=%currentcolumn%" with all %...% to there respective values offcourse.
insertion and deletion will be fairly easy too.

You could have a second table to store paths/doors and names for rooms. roomcolumn,roomrow,name,connectleft,connectright,connectup,connectdown or use a single flags column to update and retrieve the connections all at once.

You don't even have to specify how large your map will be, because you will only create new rooms as soon as you create a connection to it. Which reminds me.. Don't forget that if you make a connection up in row,col you should make a connection down in row+1,col (and left,right,down dito)

Greetings.

EDIT: you could make another column in you database where you can store the name of the current adventure, so you can make multiple adventures in the database.
If you don't want you use a database you could go for an xml like approach which would be simplest. But the you'd have to store the adventure in memory and write all when you are done. And reading it into the memory when you are going to play it.

EDIT: I did make the assumption that you are already proficient in C++, if not that would be the first thing to learn ofcourse :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
If you don't want to go for the database approach (though, that would be an excellent way to learn databases), writing a text adventure is also an excellent way to learn about object oriented programming. Consider what classes you will have (Room, Player, Enemy, Weapon whatever), what relations they have (A room can be connected to other Rooms, an Enemy will be in a Room, a Sword is a Weapon and so on) then create the class diagram in the trial version of the wonderfull Enterprise Architect and let that create all the skeleton code for you. Serialising and UnSerialising the class hierarchy into XML files is a good idea (tinyXML is one of many XML read/write packages) and for your interface I would recommend the readline library (for linux but there is probably a windows port) that will give you command history and such stuff that are absoilutely necessary and a horrible pain to write yourself.
I guess for a text adventure the Model View Controller, where you separate the model data (the class hierarchy that your world is composed of) from the way it's represented and controlled, design would be a good idea.
A common pitfall (one that I always fall into) is to start design your game before you know exactly what it will be like. Write a page about excactly what you will wan't to accomplish and don't generate any code until you're sure that you know how each part of the game will work.

Share this post


Link to post
Share on other sites
Specchum    242
Is this a programming excercise or a game design excercise? That is, do you wish to actually code the text adventure for C++ for the heck of it or do you actually want to "make" a text adventure game? Those are two seperate questions and if you answer is latter, may I point you to the excellent inform adventure (or interactive fiction as it is known now) design system:
http://www.inform-fiction.org

Inform allows you to write an adventure game using natural language. It allows you to do all the stuff you mentioned using similar natural language constructs. It's pretty powerful and is quite flexible provided you're willing to devote some time learning the nuances of using it. Hope this helps!

Share this post


Link to post
Share on other sites
Joppen    122
Thanks for the great input people!

And to specchum: Im not really out to make a big and fancy game, its the basics Im after. How are they built? What methods are used? The basic structure (code) and so on.

Sorry if it was unclear. :)

Share this post


Link to post
Share on other sites
Aardvajk    13207
It would be an interesting but unusual approach to create your text adventure world by typing commands in like that. I can see this would work for locations and objects, but I think you would find it would be very hard to extend this to describe puzzles and intereactions between objects and so on.

A more conventional approach with text adventures would be to have the world described in text files that are loaded by your adventure engine. A simple approach might be to store the location and object info something like this:


location 1 "standing in a house."
location 2 "in the living room of a house."
object 1 "a wooden table" 2 // last number would be location of object say
object 2 "a sofa" 2



and something similar for connections between locations and so on. Your text adventure engine would then need to parse this file at start up to load the information into some internally usable format before running the game.

There are plenty of third-party text adventure authoring languages available. I've been working on one on and off for a few years now whereby the engine handles parsing the player input into "logical sentances" where each word can be identified by an ID number, then provides a sort of C-like syntax for scripting the responses to inputs and so on.

To begin with though, I'd take the idea you expressed in the original post and try to convert it to read the information from a file rather than from keyboard input like that.

HTH Paul

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
What I would like to know is the actual design of Text Adventures. I know how to code one (not in C++ though, I'm just starting to learn that, darn is QBASIC limited or what). But how do you do the story, how can you keep track of what the player has done so far, which plot twists he has taken, et cetera? That's what's got me stuck.

Share this post


Link to post
Share on other sites
Aardvajk    13207
Quote:
Original post by Anonymous Poster
What I would like to know is the actual design of Text Adventures. I know how to code one (not in C++ though, I'm just starting to learn that, darn is QBASIC limited or what). But how do you do the story, how can you keep track of what the player has done so far, which plot twists he has taken, et cetera? That's what's got me stuck.


It is a pretty big topic really that can get as complicated as you want. I'd suggest you perhaps take a look at the sites for Inform or TADS. These are third party adventure authoring systems but might be able to give some clues as to the way to structure games.

I was a big fan of the Level9 text adventures back in the day. These pioneered (possbibly - don't flame me for that assertion) some quite complex non-player character behaviour and route finding and so on.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
After I asked my question I Googled it. Downloaded Inform, but haven't used it yet. Mostly I want to know the code mechanics of it, because I can use the same thing for RPGs once I learn C++. (Not the actual code, just how its done)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
After I asked my question I Googled it. Downloaded Inform, but haven't used it yet. Mostly I want to know the code mechanics of it, because I can use the same thing for RPGs once I learn C++. (Not the actual code, just how its done)

Share this post


Link to post
Share on other sites
Specchum    242
Quote:
Original post by EasilyConfused
I was a big fan of the Level9 text adventures back in the day.


Ah yes! The late nights I spent playing Scapeghost and Knight Orc on my speccy (aka ZX Spectrum)!


An adventure game can be designed and structured in different ways. One possible (and simple) way could be:

a Room class that has the following members: room id, list of obvious exits from the room, list of objects in the room (id's of objects only), any special attributes of the room (can be a bit field).

a table of strings that represent room descriptions that can be indexed using room id. That is, roomDesc[5] represents description for room 5.

an Object class that has the following attributes: object id, weight of object, a bit field representing whether it can be worn, eaten, carried or used as a weapon (you could probably think of other stuff), it's initial location (-1 if it doesn't start out active in the game), any special attribute of the object other than the ones listed previously (is hidden, or is activated etc).

A table of strings representing object descriptions that can be indexed using object id.

You could get a bit fancy and make a class container with certain properties and derive Room and Object classes from that, so that rooms and objects can be treated like containers. Perhaps a class surface too, that will allow you to place objects *on* other objects.

The language construct you wish to employ to design the levels will require you to parser that parses the input text for things like verbs, nouns, adjectives etc and take appropriate action. As you can see, things can get fairly complex when trying to interpret an input in natural language form.

Or alternately, you could perhaps write a script using natural language syntax and interpret it using tools like Python or Lua. Maybe even code your game logic using the script too!

Share this post


Link to post
Share on other sites
BladeStone    100
Even though I'm burned out on writing my game engine, I would call it a single player text game. I did get some 2D graphics working before I became exausted. I would like to know if there is anything I can help out with, including advising from my experience.

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