Sign in to follow this  
xegoth

OO Game Engine

Recommended Posts

xegoth    154
Alright I've done a few 2d games and now I'm moving into 3d. I want to make my engine pretty organized since I'm sure this will be bigger than my previous projects. Right now everything is in a big Engine class (bad). I want to split it up by Audio, Graphics, Input, Gameplay, or something like that. Now, do I declare the audio graphics input and gameplay classes inside of the greater engine class or make them global, or what? Thanks in advance.

Share this post


Link to post
Share on other sites
Etnu    880
Usually you want the classes completely independent, and then have the 'sub systems' (graphics, sound, etc.) be instanced as member variables within the engine.

Share this post


Link to post
Share on other sites
psykr    295
Making the subsystems members of a big engine class, or not is largely a style choice, up to you. I'd suggest writing them as if they're seperate though, because I find it helps clean up the code a lot (removes unnecessary interdependencies).

<rant> A word of advice about encapsulation: try to avoid singleton at first as much as possible. I find that if you don't know what you're doing, it tends to make your code all interdependent, and generally just as messy as putting everything in a big CEngine class. Try to pass variables only when necessary; for example, since Direct3D needs a window handle to be initialized, some people just make the window class a singleton, then use it in the Direct3D code. That's horrible, when all you needed to do was to pass an HWND to Direct3D.</rant>

Share this post


Link to post
Share on other sites
Eimer    184
You might want to take a look at this article (I think it's written by superpig): Enginuity
It gives an quite detailed example of how an OO engine might look like. Be sure to check out all 5 parts ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this