Advertisement

Creating a World for a Text/Menu based Life Sim/RPG

Started by October 05, 2015 03:50 PM
10 comments, last by Khaiy 9 years, 2 months ago
I would expect sublocations be locations inside other locations, eg a house in a city, a room in a house, or a bed/shower/closet in a room.
A list could work, but if you want to find sub locations by name, it's better to use a map/dictionary

You might also want to have "exits" to other locations (from one room to another), unless you want to ask the house about neighbouring sublocations.

(This starts to look a lot like an adventure game structure, it might be useful to have a look at eg inform or tads to see how they handle rooms and exits.)


Yeah, I really like the idea of using a single generic Location class. Since each location could have a variable number of sublocations, would using a 'list' to hold sublocations be a good way to solve that?

Yes, though there are other details that will matter. A common is to have each Location contain a list of references to Locations that it connects to, with the actual Locations themselves declared, instantiated, and stored in a higher-level object (like a World or Game class). That could be a list, though I'll echo Alberth that it will probably be better to use a Dictionary or map. Again, your exact approach will depend on how you plan to access and manipulate the Location objects in your game.

-------R.I.P.-------

Selective Quote

~Too Late - Too Soon~

This topic is closed to new replies.

Advertisement