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.)
Creating a World for a Text/Menu based Life Sim/RPG
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement