Game architecture: modeling different steps/types of UI

Posted by Sander on Stack Overflow See other posts from Stack Overflow or by Sander
Published on 2010-04-11T14:55:36Z Indexed on 2010/04/12 5:53 UTC
Read the original article Hit count: 244

I have not done any large game development projects, only messed around with little toy projects. However, I never found an intuitive answer to a specific design question. Namely, how are different types/states of UI modeled in games? E.g. how is a menu represented? How is it different from a "game world" state (let's use an FPS as an example). How is an overlaid menu on top of a "game world" modeled?

Let's imagine the main loop of a game. Where do the game states come into play? It it a simple case-by-case approach?

if (menu.IsEnabled) menu.Process(elapsedTime);
if (world.IsEnabled) world.Process(elapsedTime);

if (menu.IsVisible) menu.Draw();
if (world.IsVisible) world.Draw();

Or are menu and world represented somewhere in a different logic layer and not represented at this level? (E.g. a menu is just another high-level entity like e.g. player input or enemy manager, equal to all others)

foreach (var entity in game.HighLevelEntities) entity.Process(elapsedTime);
foreach (var entity in game.HighLevelEntities) entity.Draw(elapsedTime);

Are there well-known design patterns for this? Come to think of it, I don't know any game-specific design patterns - I assume there are others, as well? Please tell me about them.

© Stack Overflow or respective owner

Related posts about design-patterns

Related posts about game-development