Advertisement

Game Engine Architecture

Started by December 29, 2000 04:39 PM
4 comments, last by kieren_j 24 years ago
Hi I''m writing my first "proper" 3D game engine now ( although I say that on every one usually, until it gets too hard ) but I have a question about engine archiecture, because I doubt that mine is set out anywhere as near as it could potentially be. Here is a quick view of my engine:

*WinMain* creates
  *CApplication* creates
    *CEngine* calls (every frame)
      *CIntro,CMenu,CGame,COutro*
 
Or here''s a diagram I made up for myself, might be easier to understand?

      WinMain (winmain.cpp) 
            |
           \|/ calls
   CApplication::EntryPoint  (application.cpp)
  |                |                 |
 \|/ calls        \|/ calls         \|/ calls
CEngine::Create  CEngine::Frame  CEngine::Destroy (engine.cpp)
         |            |              -(same, calls ::Destroy funcs)
         |            |
      +--|----------+-+--------+--------------+          }
      | calls       | calls    | calls        | calls    } called by
     \|/ |         \|/        \|/            \|/         } CEngine::
   CIntro::Frame CMenu::Frame CGame::Frame COutro::Frame }     Frame
         |
         |
 +-------+------+------------+----------------+           }
 | calls        | calls      | calls          | calls     } called by
\|/            \|/          \|/              \|/          } CEngine::
CIntro::Create CMenu::Create CGame::Create COutro::Create } Create
(intro.cpp)     (menu.cpp)    (game.cpp)     (outro.cpp)
 
Maybe not. Please tell me what you think? Thanks
Its a start...
There''s not too much detail there to know what exact you want to accomplish.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
Hi again

I should have explained maybe a little bit more. My engine is like a global state-machine. The CEngine class creates instances of CIntro, CMenu, CGame and COutro objects. A member of the CEngine class, "EngineState" holds the current game state. The corresponding object''s "::Frame" member is called (i.e. depending on the EngineState value).
What I''m wondering is if this is very efficient way of setting out an engine, and if not, what would be a better way ?

Thanks for replying
Hi again

I see my options as this:

1. My current layout is fine
2. Needs to be broken down more
3. Needs to be grouped together more
4. Needs to be started again
5. Needs to be moved around

Votes and/or comments please!

Thanks
I think it would be beneficial to break your engine up in parts that are as independant as possible. If, for example, some application does not require the class 'CMenu' then you would have to alter the CEngine class to remove it etc. So perhaps its best to make the CEngine class some kind of register that keeps track of its 'child' objects. To do that, you would need a baseclass from which every class inherits.

Let me clarify:

  class CBase {public:    virtual void create() = 0;    virtual void destroy() = 0;    virtual void frame() = 0;};class CMenu : public CBase {// ...};class CGame : public CBase {// ...};void Application::entryPoint(){    CEngine engine;    engine.add(new CMenu());    engine.add(new CGame());    // ...    engine.create();    while(inGameLoop){        engine.frame();    }    engine.destroy();}class CEngine : public Base {protected:    // Array template that stores registered items    Array<Base*> baseArray;public:    void create(){        Iterator i = baseArray.iterate();        for(i.first(); !i.atEnd(); i.next()){            i.current()->create();        }    }    void add(Base *b){        baseArray.append(b);    }    // ...};  


Hope this gives you some inspiration.

Edited by - Countach on December 30, 2000 3:29:13 PM
-------homepage - email
Hi again

Thanks for replying. What you have given seems like a very efficient method for creating and managing objects in a very dynamic way. However I don''t really need this, because I have a design document saying the 4 states will not be changed / others added; but I may use this sort of idea for game objects, if thats ok with you?
I assume that because you are my only response there''s nothing wrong with my archiecture

Thanks again

This topic is closed to new replies.

Advertisement