jeudi 23 août 2018

How To Properly Structure a Game Engine

I am starting to write a game engine in c++, and have decided to impliment it like so:

class Game
{
    public:

    Game() {};
    virtual ~Game() {};

    void play()
    {
        begin();
        gameLoop();
    }

    virtual void begin() = 0;

    void gameLoop() {/*Game Loop...*/};
};


class TestEngineGame : public Game
{
public:
    TestEngineGame() {};
    ~TestEngineGame() {};

    virtual void begin() {/*Gameplay Stuff etc.*/};
};


int main(int argc, char *argv[])
{
    TestEngineGame game;
    game.play();

    return 0;
}

Is this a good way to impliment an engine? More spesifialy, should my Game::play() function do as it does? If not what would be a better implimentation? Thanks in advance:)

Aucun commentaire:

Enregistrer un commentaire