Engine Architecture
The big picture of major game engine design has always been somewhat elusive to me. I previously explained how I view it as an operating system, but that analogy of course is not always appropriate. Entity management, complex environments, and collision/physics all serve to make the problem unique.
Yesterday, I realized I was trying to abstract far too many things away, which ultimately gave me inadequate control over my system or spawned technical 'solutions' that were less than stellar. One of my biggest problems was that of managing my scene with all its various entities moving around and GUI elements.
Initially, I tried to have one generic SceneManager which kept a list of Drawable objects and would handle drawing them accordingly in a very naive fashion. I would keep a separate World or Level object to control the various entity interactions. This tightly coupled two subsystems to the Drawables and did not provide me with much flexibility over how they should be drawn. Lately, I've been seeing that I need to merge the two - I need one master Scene object which would handle both entity interactions and drawing the entities. Having a much fuller knowledge of the entities, it can provide certain optimizations and give greater flexibility. Of course, it doesn't come without cost - it's a lot less generic and becomes a lot less reusable, which is why I'm still very hesitant about switching.
Another implication of this is that I have to split my GUI and Scene information. Again, before, I could just shove everything into the SceneManager including GUI widgets, since it was responsible for drawing and nothing else. But this requires special, non-general information in the Drawable class to differentiate between those objects which must move with the scene and those that must not. An ugly hack, basically - one which I didn't need when I was using OpenGL because I could rely on the matrix stack to handle these problems, but now that I'm using XNA's 2D functionality, it becomes essential.
I still haven't settled on the merge of SceneManager and World. It seems cleaner in some respects but less robust in others. I think I'm just going to have to play with both methods more until I settle on one.
Yesterday, I realized I was trying to abstract far too many things away, which ultimately gave me inadequate control over my system or spawned technical 'solutions' that were less than stellar. One of my biggest problems was that of managing my scene with all its various entities moving around and GUI elements.
Initially, I tried to have one generic SceneManager which kept a list of Drawable objects and would handle drawing them accordingly in a very naive fashion. I would keep a separate World or Level object to control the various entity interactions. This tightly coupled two subsystems to the Drawables and did not provide me with much flexibility over how they should be drawn. Lately, I've been seeing that I need to merge the two - I need one master Scene object which would handle both entity interactions and drawing the entities. Having a much fuller knowledge of the entities, it can provide certain optimizations and give greater flexibility. Of course, it doesn't come without cost - it's a lot less generic and becomes a lot less reusable, which is why I'm still very hesitant about switching.
Another implication of this is that I have to split my GUI and Scene information. Again, before, I could just shove everything into the SceneManager including GUI widgets, since it was responsible for drawing and nothing else. But this requires special, non-general information in the Drawable class to differentiate between those objects which must move with the scene and those that must not. An ugly hack, basically - one which I didn't need when I was using OpenGL because I could rely on the matrix stack to handle these problems, but now that I'm using XNA's 2D functionality, it becomes essential.
I still haven't settled on the merge of SceneManager and World. It seems cleaner in some respects but less robust in others. I think I'm just going to have to play with both methods more until I settle on one.

0 Comments:
Post a Comment
<< Home