Rooms for a text game

Started by
1 comment, last by Cgr 15 years ago
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?
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.
Create-ivity - a game development blog Mouseover for more information.
Wow very insightful, thanks for the information, Captain P.
Should help a bunch.

This topic is closed to new replies.

Advertisement