For now I have a list of basic data class like position in game world, dimensions, type and stuff like that, but since I am starting to implement their functionality it seems kind of a bad pattern, I need each zone to have totally different data and behaviour, use different UIs etc, is there a pattern to realize that other that just making one totally different class for each zone?

  • \$\begingroup\$ Do you know anything about the state machine pattern? \$\endgroup\$
    – Vaillancourt
    Mar 10, 2016 at 21:36
  • \$\begingroup\$ A zone is a limited piece of the game world with some particular functionality, for example a zone where units gain health over time, or a crafting factory where you can build new units, that's the problem, there are quite different things they can do. \$\endgroup\$ Mar 10, 2016 at 22:01
  • \$\begingroup\$ Can you give a specific example? \$\endgroup\$ Mar 10, 2016 at 22:53
  • \$\begingroup\$ I gave it the post above... \$\endgroup\$ Mar 10, 2016 at 22:55

1 Answer 1


You can use something like a component based, inheritance or composition architecture. You have plenty of options here, and it really boils down to your own style and the requirements of your game.

For a quick implementation, I would probably a simple form of component based architecture. Probably making the components and systems using inheritance. This would allow me to create systems and components that share some functionality, like modifying the attributes of the unit inside their bounds, or creating new units, or whatever's needed. Then when making the zones, I can mix and match components to build whatever kind of zone I want.

Zones would then be defined with the list of components you want them to have. For example adding a "Modify health" component and an "Every X seconds" component would provide your heal-over-time functionality. Or adding a "Modify health" component (with a negative value) and a "Single use" component would create something like a landmine.

I think this will give a good mixture of the two architectures and be flexible enough to provide a lot of options for zones.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .