Sign in to follow this  

Separating Engine from Game?

This topic is 3043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I apologise in advance if this question has been answered somewhere else, but I had trouble finding what I was looking for. Essentially, I'm looking to build a good reusable Engine for a few projects of mine. The problem is, I'm unsure of how to go about separating the Engine code from the game code itself. I'm familiar with all the basic aspects of game design, DirectX/OpenGL, Audio, Input handling and so on but the best I can manage is to just have these components in separate header files that I can include in a project. I know there must be a better way of doing this, perhaps by compiling the engine as a library and linking that to other projects, but that's what I'm having trouble working out. I've never written a library or DLL or anything like that, so I'm not sure where to begin, or if that's even the right way to go. I keep searching for articles on separating an engine from game code, but invariably keep finding tutorials on building OpenGL engines and such, which isn't quite what I'm after. Can anyone point me in the right direction? Thanks!

Share this post


Link to post
Share on other sites
It depends what your engine should be capable to do. you could start by making a new folder called "engine" and add all the classes you would need to complete each of your games, e.g:

#include "InputAudioGraphics.h"

class Engine {
Engine();
bool start();
bool render();
bool keyIsDown(int key);
};

Then make a new folder for your game and don't add any header files from your game into your engine.

Share this post


Link to post
Share on other sites
I have started a series of articles on starting a game engine. Part 1 goes over defining some project requirements. Part 2 goes over setting up a visual studio dll project and linking it with either a UnitTest++ test app or just a test console application.

Hope it helps. And feel free to comment on the post if anything is giving you trouble and i will see if i can help.

Share this post


Link to post
Share on other sites
Thanks, Wizecoder, that almost seems to be what I'm looking for.
Could you possibly expand a little on part 2? You give a good description on what to do, but you don't really give reasons as to why you should do it. You also seem to assume that the reader knows all about DLLs, how to access them and such which is the bit I'm kind of struggling with. Perhaps that is to come in part 3?
Thanks again, I think you've helped me on the right track so far.

Share this post


Link to post
Share on other sites
I will look into improving it but to tell you the truth that article shows a lot of what i already know. I still don't have loads of experience and a lot of this is the result of reading the MSDN docs, reading articles about unit testing and perusing the Ogre3d source code.

But I will try and expand on it but at the same time if you have any suggestions please do comment on the blog post and i will try to add it in.

PS. If you want to learn more about dll's i would recommend perusing around here and here.

Share this post


Link to post
Share on other sites

This topic is 3043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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