Separating Engine from Game?

Started by
4 comments, last by Wizecoder 14 years, 8 months ago
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!
Advertisement
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.
Yeah, that's sort of what I'm doing at the moment, but as I said I believe there must be a better way of doing it.
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.
Check out my new blog: http://beefmachinegames.wordpress.com
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.
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.
Check out my new blog: http://beefmachinegames.wordpress.com

This topic is closed to new replies.

Advertisement