Jump to content
  • Advertisement
Sign in to follow this  
Cgr

Rooms for a text game

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

Beginner here, and open to all forms of criticism :) My goal is to make a text game/engine from scratch.
RoomHandler.RoomList[13].Name = "Cave";
RoomHandler.RoomList[13].Description = "It's dark and spooky.";
RoomHandler.RoomList[13].southExit = 56;

RoomHandler.RoomList[56].Name = "Cave Entrance";
RoomHandler.RoomList[56].Description = "You are at the mouth of a cave.";
RoomHandler.RoomList[56].northExit = 13;
This is only a quick example, but problem is, I need to make hundreds of rooms. And of course, creating the rooms by hand becomes tedious and largely error-prone. I suppose the answer to this solution is a Room Editor, but have two questions: 1. Does a Room Editor like this already exist? Where can I find one? (I want to focus on the game itself, not engine utilities...) 2. My intuition says, something is flawed with my code. What is a better way of coding the rooms and why?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Cgr

RoomHandler.RoomList[13].Name = "Cave";
RoomHandler.RoomList[13].Description = "It's dark and spooky.";
RoomHandler.RoomList[13].southExit = 56;

RoomHandler.RoomList[56].Name = "Cave Entrance";
RoomHandler.RoomList[56].Description = "You are at the mouth of a cave.";
RoomHandler.RoomList[56].northExit = 13;

That looks like it could easily be made data-driven. Load it from a text file or such instead. Then you no longer need to recompile the game when you're simply changing rooms. Oh, if you're working with C++, make RoomList a std::vector. You can then simply .push_back() room structs/classes into it, without having to worry about those indices. I've seen code like yours before, and it's surprisingly brittle. Change the size of the array or remove a room and you'll get all kinds of subtle and not-so-subtle problems.


Anyway, about the data, you could simply use Excel or Draw for this (outputting .csv files, or some other format that's easy to parse), although then you'd still have to manually ensure that rooms are connected. You could write a little script that checks the output for such logical errors though.

You could write a full-fledged editor for this as well, although I don't see how that would give you any significant benefits over just using an existing spreadsheet editor.

As for linking rooms, you'll probably want to use names or id's or something instead. Currently, things start to break down when you remove a room or two.

Share this post


Link to post
Share on other sites
Wow very insightful, thanks for the information, Captain P.
Should help a bunch.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!