Engine design

Started by
2 comments, last by rip-off 16 years, 10 months ago
Currently my engine is made up of a bunch of components - Renderer, Input Manager, Sound Manager, Interface Manager, etc. The implementation details of all these classes is hidden - encapsulated so the internals of the Renderer, for example, are not accessible to anything other than the Renderer. However, I see there might be a problem. My Sound Manager could access the Renderer and call ToggleWireframe(), if it really wanted to, and cause the entire frame to be renderered in wireframe. Or, my Renderer could access the Interface Manager and call CreateButton() and spawn buttons all over the screen for example. It seems to me that this shouldn't be allowed - where each class can arbitrarily access every other class's functionality. Should I bother to take steps to prevent this from happening? If so, how should I go about doing this?
NextWar: The Quest for Earth available now for Windows Phone 7.
Advertisement
Don't go so mad.
in c++ you can do all kind of things, if you really want to.
so just use right engine design when all engine subsystem are independent from each other.
-=<KoraK>=-Skype: denis.ovod ICQ: 18945737
I might have got your question wrong, but I believe that some encapsulation (data hiding) would help you out here.
Simply put your "hidden functions" under the private or protected keyword, that would assure you that only the class itself can use those functions.

EDIT:
Miss read, but how can another class use those functions if you're hiding them?
I think you'll have to explain the "if it really wanted to" statement.
Check out my devlog.
The only way an InputManager could call a function of a Renderer is if it has a reference to it, or the Renderer is some kind of global (or, *shudder*, a Singleton).

So ask yourself, why can my InputManager talk to my Renderer, and how can I rig it so that such communication is impossible.

This topic is closed to new replies.

Advertisement