Sign in to follow this  

Wanna make a txt rpg...how to go about it

This topic is 4340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Gamedev! I've been learning c++ and have made a few (basic) txt games. I would like to make a txt based rpg. VERY small starting out. Like 5 rooms. Basics that i want: weapon class, char class, enemy class, very basic inventory and a simple engine. Now if i move on to wanting to add more rooms is there a shortcut to generating rooms? Could i possibly do a multi dim string array that will store about 35 or 40 sentences and then randomize which one is the 'room'? or even randomize two or three? My question is this: is there a better way for room creation? I know there is but i'm drawing a blank. I hate to sound like a complete noob... but i am and I REALLY want to learn. Any hints or tips would be appreciated. Thanks alot!

Share this post


Link to post
Share on other sites
Hello, tidalton!

To tell you the truth, I have not touched anything like a txt RPG before. But:

Perhaps you could have a room class, wich has a function for adding new rooms. Including in this functions arguments should be a STL string(These strings are much easier to use than normal char arrays) . This string represents a txt file wich contain a description of the room(IE. You enter a dark and spooky cave). Some arguments must be used to determine wich rooms this room connects to. So that you can acctually enter this room.

My advice is to just sit down and figure out what such a function needs. And then design your class(es) and game into a simple word document. Planning and design is pretty much required for a text RPG. After you have done that, you have gained a basic understanding of what needs to be done and how to do it. Then you can start coding.

Happy coding, and good luck!

Share this post


Link to post
Share on other sites
This one always make me smile:

Quote:
Original post by tldalton1622
VERY small starting out. Like 5 rooms.


50 rooms isnt all that much more work than 5 rooms. You make a class that represents a room. It contains a string that is the description of the room and maybe a vector for the items here and a vector for the monsters that are in the room. Once you have that class and a system to load rooms from files you can puke out 5 rooms every minute! [smile]

If you load a room from a file, the only thing really you wanna load is the description of the room, monsters and items should be randomized. That is so that the room "A small, round and dark room, the walls are covered with blood" will not always have two goblins and a couple of gold coins in it.

Good luck with your project! [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Mizipzor

50 rooms isnt all that much more work than 5 rooms. You make a class that represents a room. It contains a string that is the description of the room and maybe a vector for the items here and a vector for the monsters that are in the room. Once you have that class and a system to load rooms from files you can puke out 5 rooms every minute! [smile]

If you load a room from a file, the only thing really you wanna load is the description of the room, monsters and items should be randomized. That is so that the room "A small, round and dark room, the walls are covered with blood" will not always have two goblins and a couple of gold coins in it.

Good luck with your project! [smile]


Exactly so. [smile]

Share this post


Link to post
Share on other sites
Hehe looks like a reposted your exact advice. :P Maybe I should start reading through the thread before posting. But you know, now with two different explanations, he must really have understood the point, lol. [smile]

Share this post


Link to post
Share on other sites
I have never created a full text RPG, I have tried to though. The methods i was using to create the game we're very "noobish" because I tried this only a few weeks after having a very basic understanding of C++. I setup a character creation menu and a fighting system for my game though. The character creation was finished, a few problems that could have been fixed if I knew anything about classes and stuff. The fight system allowed the user to either run from battle or fight. A random monster would appear and tell you "(Monster name here) has attacked you!", or something like that. Damage and health worked, never got any further than that. If you have questions, pm me and ill be glad to help you out where you need it.

Share this post


Link to post
Share on other sites
You'd probably need a scripting language..

So you script what happens when users types a word, or does something.
There's the sourcecode for an opensource ScummVM floating around
the internet (that's the interpreter for the old lucasarts clasic
games, like maniac mansion and zak mc cracken).
Maybe looking into it or docs for it will help you see how it works,
and how to do sth simular in your game.

Some quick prototyping - maybe that'll give you ideas

enum eDirection
{ NORTH, SOUTH, ...
};

class Object
{ String name;
};

class Weapon : public Object
{
};

class Room
{
private
String RoomName;
String onEnterText;
public:
vector<Object> itemsInRoom;

void onEnter (void) { /* display onEnterText */ }
};

class RoomMgr // singleton
{
struct connection
{ int toRoom;
int fromRoom;
Direction dir;
}

vector <Rooms> rooms;
vector <connection> fromToRoom;

RoomMgr ()
{
// make sure rooms[0] is invalid, since we'll use 0 for invalid index
rooms.resize (1);
}


int addRoom (const Room& _room) { rooms.push_back (_room);
// add a connection to go from one room to another room
void addConnection (const String& fromRoom, const String& toRoom, Direction _dir);

int canGoInDirection (int currentRoom, Direction _dir)
{
for (int i=0; i<fromToRoom.size(); i++)
{
if (fromToRoom[i].fromRoom==currentRoom && fromToRoom[i].dir==_dir)
return fromToRoom[i].toRoom;
}
}
};


void Game
{
private:
int currentRoom = 0;

void setCurrentRoom (int id)
{
if (RoomMgr::isValidRoom (id)
{
// check for null :)
Room* oldRoom = RoomMgr::Instance().getRoom (currentRoom);
oldRoom->leave();
Room* currentRoom = RoomMgr::Instance().getRoom (id);
currentRoom->enter();
}
}

void userEnteredString (const String& userInput)
{
if (userInput=="NORTH")
setCurrentRoom (RoomMgr::Instance().canGoInDirection (currentRoom, NORTH);

}
}

Share this post


Link to post
Share on other sites
Ow! Kitten! He's just learning C++ and wants to make text strings for rooms... "You probably need a scripting engine" probably isn't what he wants to hear right now :p

The original question sounded like you wanted an automatic room generator, rather than having to type in all the rooms yourself. I don't think I've ever seen such a thing for textual room descriptions, though it's certainly possible, but rogue-likes (text drawings of rooms, top down) definitely do a lot of it.

Share this post


Link to post
Share on other sites
I agree about the scripting language. Right now im JUST trying to concentrate on c++. I still havent gotten to competant programmer in c++ so i dont want to branch off. I REALLY want to be a damn good programmer. I know that its skill as much as knowledge... but i want to learn the skills needed to use the knowledge. if that makes sense.

EDIT: GREAT idea about the class rooms. Didnt even dawn on me. That gives me ideas about the constructor and those random stl's i was thinking of for randomizing a room description....

TLD

Share this post


Link to post
Share on other sites

This topic is 4340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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