World design help?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
freezzo
Posts: 27
Joined: Thu Mar 08, 2007 6:36 pm
Contact:

World design help?

Post by freezzo »

I am thinking up an idea in my head for the design of how I am going to manage my environment. Basically I want to create an easy to use system for adding areas to a world etc and was curious to have some feedback.

The idea is to have concepts of a World, continents, zone, etc. I was wondering if I should use inheritence like so

class World {};
class Continent: public World {};
class Zone: public Continent {};

Or would it go the other way around:

class Zone();
class Continent: public Zone {};
class World: Continent {};

The other way, is iwth no inheritence and each class just holds a contain that has all of its children in it.

What do you think?
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Is a world a continent? No. Is a continent a world? No.

So no inheritance is not the way to go but having a list of continents in a world should be ok.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
freezzo
Posts: 27
Joined: Thu Mar 08, 2007 6:36 pm
Contact:

Post by freezzo »

I agree with that. The reason why thinking inheritance would help would be in a case such as the position of the world changed, every child item would move with it, etc.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

The reason why thinking inheritance would help would be in a case such as the position of the world changed, every child item would move with it, etc.
Whaaa? :D
Why would the world need to move :roll:
Working on game: Marrbles (Currently stopped).
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

freezzo,

If we talk about class organization, i would probably did something next:

class zone; // abstract or interface
class indoor : zone; // like cave, house ... or if i need more, i would "class house:indoor;", "class cave:indoor;" and so on.
class outdoor : zone; // like street, airport or a beach

The collection of this zones like continents and world, can be achieved next way:
class region; // this class manages collection of zones (usual this zones are close to each other, but that is not a restriction)
class continent; // ......... manages collection of regions
class world; // ................. manages collection of continents
freezzo
Posts: 27
Joined: Thu Mar 08, 2007 6:36 pm
Contact:

Post by freezzo »

serengeor wrote:
The reason why thinking inheritance would help would be in a case such as the position of the world changed, every child item would move with it, etc.
Whaaa? :D
Why would the world need to move :roll:
What if the world was part of a solar system?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Erm you didn't say anything about Solar system You CHEATER! :lol:
Working on game: Marrbles (Currently stopped).
Post Reply