Game engine structure question
Posted: Mon May 07, 2012 2:47 pm
ok so i have a question about game engine development for example i have 2 classes:
and the question is, is okay to use the graphics constructor in engine.cpp that includes engine.h that inherit from graphics class instead than in graphics.cpp
and in the graphics.cpp just define what the function draw image is going to do
so then in the main.cpp whan i call the function DrawImage(); i call it this way
is ok to do it that way so every function in my graphics class i call it from my engine class that inherit them???
so if i do the same thing also with a sound class instead off calling each function from its respective class i call them from my engine class that inherit them.
and is there any way to have in the engine class a funtion called for example "StartEngine()" that initialize al the constructors from my other classes like sound, graphics input etc ?? thanx for your time
Code: Select all
"graphics.h"
class graphics
{
public:
graphics();
~graphics();
void DrawImage();
}
"engine.h"
class engine: public graphics; //that inherit from graphics class
{
public:
engine();
~engine();
}
and the question is, is okay to use the graphics constructor in engine.cpp that includes engine.h that inherit from graphics class instead than in graphics.cpp
Code: Select all
"engine.cpp"
#include "engine.h"
engine::engine(){}
graphics::graphics(){}
Code: Select all
"graphics.cpp"
#include "graphics.h"
void graphics::DrawImage()
{
SDL_BlitSurface(...);
}
Code: Select all
int main(int argc, char *argv[])
{
engine engine;
// son now i call tha function DrawImage() like this
engine.DrawImage();
//instead of
graphics.DrawImage();
so if i do the same thing also with a sound class instead off calling each function from its respective class i call them from my engine class that inherit them.
and is there any way to have in the engine class a funtion called for example "StartEngine()" that initialize al the constructors from my other classes like sound, graphics input etc ?? thanx for your time