Sign in to follow this  

navigable text world theory/implementation

This topic is 3593 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

C++ to revive my interest in programming, im reviving my years-old C project of a scalable text RPG enging (within reason), except now its being written in C++. originally, i had the "world" as a struct-based tree. for C++, then, im trying to use a std::list<> of "Room" classes with pointers (north, south, east, west, up, down) to other rooms. each "Floor" will contain some "Rooms", each "Building" will contain some "Floors", and so on. now, in the infancy of this navigation system, im just trying to set up a single floor with a few rooms to get things rolling. as im attempting to initialize th whole thing, im running into problems. first, how would you go about elegantly/efficiently each room? ive got the constructor filling in the information based on which room is being constructed (the floor constructor actually calls the room constructors), but then im not sure how to properly arrange the pointers / link the rooms together without manually doing it one-by-one. is there some smooth way to accomplish that? furthermore - is there a better model to be using for this all together? share all of your ideas! =) just be sure to at least give me an article or something if its some radical concept. ;)

Share this post


Link to post
Share on other sites
Well hey, if it's text based you could use just a 2D array. If you want to have up and down then you need to consider size requirements and such. If you're looking at like 1-room dungeon affairs, you could imply have a 'room below' link. If you NEED a 3D navigable world, you could use a 3D array, but it could be costly in resources if you're not careful. Alternative you could approach it a different way.

Have a simple 1D array of 'rooms'. For each room you could add 'keyword exits' such as:

exit[x].keywords =
West<separator>Door<separator>Outside
(multiple alternatives for exits)

exit[x].target =
RoomID
(the room that the exit will move you to)


This gives you better opportunity for one-way exits/teleports/special events. Exits act like objects which are mapped to keywords. You would 'use' them to move to another room. This would make it harder to keep track of where everything was, you'd need to keep your own diagrams and notes, but it's more flexible and less wasteful than a 3D array. You could assign the exits to a room, or you could simply add elements to the room info for a number of exits.

Share this post


Link to post
Share on other sites

This topic is 3593 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