C++ Text based game tutorials (where can I find some)

Started by
3 comments, last by RayOfAsh 18 years, 9 months ago
I have been looking at Google and havent found any that help (most were in foreign languages.) Do any of you guys know of any? I know the "basics" of C++ and am looking on how to turn the basics into something creative.
The return of NWN is the will of the gods; and i, am their instrument.
Advertisement
If you already know how to read user input and how to write "results" back, you know all there is to know.

The rest is, well, creativity and general programming knowledge (knowing what you want to do and how to do it).


What are you looking for? Ideas or algorithms?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I think mostly algorithom(sp?), which I am not good at. I used to be writing one using functions (void) but that wasnt very efficient. I have an idea to store all of the text into a data file, have the game read it, and then display it back, and then the player inputs a command and it acts upon it. Example:

In the file it may look like:

$N: room1
$D: You are in a dark room.
$E: east(room2); west(room3);

(%N(ame) $D(escription) $E(xits))
When the player plays it should look like this:

"You are in a dark room, you can go:

east, west."

And upon typing east or west it would take him to room2 or room3. I know how to read and write to files, but I dont know the algorithom to have it go through the whole file and look for little symbols (In the example the were $N, $D, $E), and then display a list (like the exits).
The return of NWN is the will of the gods; and i, am their instrument.
Quote:Original post by RayOfAsh
I think mostly algorithom(sp?), which I am not good at. I used to be writing one using functions (void) but that wasnt very efficient. I have an idea to store all of the text into a data file, have the game read it, and then display it back, and then the player inputs a command and it acts upon it.



Take a look at some of the open source implementations for running games such as the Zork series and Hitchhikers Guide to the Galaxy. These were text based games written in the early to mid 80's that used a common engine for 'scripted' games. for the era they were pretty robust in the parsing, processing, and interpretation of text input from the user. Back then games like these were fairly popular and just about every platform had games like this in one form or other. The interesting thing about games such as Zork and Hitchhikers Guide is that the same script was used on all platforms while the engine itself was either ported or implemented from scratch for the target platform.

Zork Trilogy. This includes downloads of the actual game so you can play it: http://www.infocom-if.org/downloads/downloads.html

Online version of Zork (play in your browser via Java): http://www.xs4all.nl/~pot/infocom/zork1.html

Adventure Definition Language. This is a good starting point to see an already implemented engine for text based adventure games. Excellent if you want to create an adventure game and don't want to create an engine. The syntax is pretty close to the example in your post: http://sourceforge.net/projects/adl/

I am very familiar with old adventure games, I own the original Hitchhikers Guide for the Apple 2, case and everything, even the little bag with the microscopic intergalactic space-fleet. And I own a Commodore 64.

Thank you for the links, Zork is an awesome game.
The return of NWN is the will of the gods; and i, am their instrument.

This topic is closed to new replies.

Advertisement