Archived

This topic is now archived and is closed to further replies.

peter_b

How do you structure your applications?

Recommended Posts

Im revising the design of how i structure some highlevel stuff. Like ticking all the systems, handeling user input, render output etc.. I would be very intrested in how the rest of you do it? Is it common to use the model-view-document or the MVC patten''s in games? Maybe some variant? Or maybe you have come up with some own really nice way to structure it? It would be greatly appreciated if you could explain it, and maybe a few comments on why you have decided to make it that way. :-) Thanks in advance. // Peter

Share this post


Link to post
Share on other sites
Structure? Structure? Pure spaghetti code! Whip out the gotos and labels galore. Functions, we don''t need no stinking functions!

Hmm, the best way I structure depends on what I am doing. When I cutting out in a new territory I usually write a few dozen toys to test it out and get an idea what works and what doesn''t.

Share this post


Link to post
Share on other sites
I''ve not used MVC for any games yet; I think I would just find it confusing, and as you''re unlikely to have different views or controllers, there seems no point.

On the other hand, I do use some kind of structure.

What I normally do is:

- Create a "Manager" class for each major subsystem
- Use polymorphism for my entities, sometimes I could have more levels of polymorphism, like breaking down GameObject-Collidable-PlayerShip

In my main method, after calling any really critical early init functions, I create an on-stack instance of each of my manager objects, passing references to the other ones if necessary, and then start the game by calling something like gameManager.mainLoop()

If an exception occurs during initialisation, the managers which are already completely constructed will neatly have their destructors called, and my main exception handler will kick in (usually to log or inform user)

Common managers to have - GameManager (lifetime, 1 game - does not exist in the top menu) - ResourceManager (Loads images, sounds, level data etc) (created at start of day), Entitymanager or something (inside GameManager)

Whether this is a good approach, I couldn''t tell you, but it seems to work for me.

Mark

Share this post


Link to post
Share on other sites
Enginutity layout I''m using this as a referencepoint for building my engine. I know, a kernel for an engine?! What is he thinking?! But its better than a while(1) loop. A kernel brings together everything into one coherent project. Now, if you excute me, I have some kernel hacking to do.

Share this post


Link to post
Share on other sites