Please help with class design.

So I want to make a classic dungeon crawler in the console. Would it be bad to have each room a child class of a parent class? There is going to be a lot of rooms, and each will be vastly different than others. Which doesn't give me the option to copy the same class over and over again to make minor adjustments.

If so, should I have the base class in one header and all the other child classes in another header? I'm definitely not doing a header for each child class.
I wouldn't go that route at all.

I would create a gamemap like:

N NE E SE S SW W NW U D // room 0
N NE E SE S SW W NW U D // room 1
N NE E SE S SW W NW U D // room 3
N NE E SE S SW W NW U D // room 4
N NE E SE S SW W NW U D // room 5

and so on... replace the direction with the room number you want for example

-1 2 5 -1 4 3 -1 -1 1 -1 // room 0 -1 = can't go that way, else = your new room number.
Then it would be a simple matter having a short and a long description set into an array (or vector)

When you enter room 2, display the short (or long) description. Remember, text adventures, dungeon crawlers, interactive fiction (whatever you want to call it) is 90% smoke and mirrors. I wrote a few of them back in the day when commodore 64's ruled the world of home computers. Making your map, (grouping the rooms correctly) and placing some objects is half the battle. It is the hardest part of the design. There are a lot of nice little tricks to help you out along the way. I am learning the C++ coding side of it now, but designing the game and explaining how something works is a breeze.
Separate your code and your data.

The contents and behavior of each room should not be "hard-coded" into your game, but instead should be stored elsewhere so that it is easily modifiable.

I went over examples of this in another thread a long time ago... it isn't 100% on point because it's regarding a text adventure and not a dungeon crawler -- but you can still draw some ideas from it:

http://www.cplusplus.com/forum/beginner/121532/#msg661754
Topic archived. No new replies allowed.