Advertisement

Text-based engine...

Started by February 20, 2001 06:30 PM
1 comment, last by intPointer 23 years, 11 months ago
Hello all. Just a quick question, maybe someone could point me in the right direction. I''m looking to do my first game as a simple text-based game (like the original Zork and such.) I have all those books on 2D game programming but I want to hold off on doing a 2D game. Anyways, I''m now exactly sure where to start on for this text-based game (btw, I''m using MS VC++ 6.) I''m thinking of making each map/room a simple .txt file that the engine will read. Contained in that file will be all the information for that room (such as which ways the player can go, any objects in the room, descriptions, etc.) Is this the best way to go about doing it and if so how would I implement it? The other thing I was wondering about was getting input from the player. The engine needs to be able to recognize what the player is typing. For instance if the player types "get " then the engine needs to be able to know what to do. I''m having difficulty with that concept though. Any help would be appreciated, code that I could look over would be even more useful. Thanks a bunch!!! Gary Phillips lighttheskyonfire@juno.com AOL IM: thestylites
Gary Phillipslighttheskyonfire@juno.comAOL IM: thestylites
k making a text based rpg isnt to hard you make your character, enemy, npc, room, and item classes.

My rooms where an array of 10x10 and I used a text file to init the ones that you could walk in they were kind of like this

class room
{
public:
bool north;
bool west;
bool east;
bool south;
char name[50];
char desc[500];
};

the north,west, etc.. are all flags to test if the player can move in the next direction. I used a switch statement for my input one for the verb and one for the noun. if you need any more help my icq # is 99213462
or you can email me at OoMMMoO@hotmail.com
Advertisement
Text-based games are more difficult to make than you probably imagine. Parsing the input from the player is the hardest part, I would think, although I''ve never actually written such a parser. Perhaps you could try using menus rather than natural language input if you''re willing to take some freedom away from the player.

As for constructing the world out of .txt files...
Keep in mind that objects will [most likely] need to be shared between rooms and will change depending on the state of other rooms. This might be difficult to manage if your rooms are completely separated from each other.

I have seen several games that use one text file to describe the world. You would, for example, create a diamond object and a room object that contains the diamond. Each room has directions to other room objects and so on.

Of course, you will also need some sort of a parser for your world .txt files.

I hope I was able to help. Good luck with your game!

This topic is closed to new replies.

Advertisement