Main classes of interest

From IrrWizard

Jump to: navigation, search

Contents

Directory structure

folders.jpg

Directory structure of the Full Framework. The Core Framework has the same structure but without the engine folder.

Core classes

  • CGame
  • CGameManager
  • CGameState
  • CGamePlayState
  • CGamePlayStateLevel01

CGame

Contains the main game loop and creates a reference to CGameManager. The Update function on CGameManager is called each iteration of the game loop. No modifications to this class should need to be made.


CGameManager

This class is responsible for controlling the game flow logic using a 'State Pattern' approach. The CGameManager holds a pointer to a state object. This is genrally the current screen of the game, ie Introduction screen, Level01, credits screen etc.(although could represent a paused state, more about this later).

This class may also store pointers to other managers, for example a CPhysicsManager or CSoundManager.

The CGameManager doesn't change the state, in fact it knows nothing about the state at all, it's the task of the state to change itself. It performs a marshaling job by calling the current states Clear() function before calling the next states Init() function. The pointer is then updated, now pointing to the new state.

This class acts as the main entry point or driver to the Irrlicht API. No other class should use or reference it directly but go through the CGameManager. Functions to access the main Irrlicht subsytems are provided, ie getSceneManager(), getDriver(), getCollisionManager() etc.

For example:

pManager->getSceneManager(); 


Will return a reference the Irrlicht SceneManger.

In theory this will allow the rendering engine to be swapped out without effecting any of the game code, of course the CGamemanger will need quite a bit of changing.


CGameState

The main base state class, all states inherit from here. The 3 main functions, Init(), Update() and Clear(). It also has an OnEvent() function which can be overridden for keyboard and mouse support. Each game state has its own game loop which is controlled from the Update() function. (The CGameManager will call the current states Update() function each game loop. No modifications to this class should have to be made, all code should go in it's child classes.


CGamePlayState

Inherits from CGameState to provide general game play functionality. All generic code should be added here. ie. Health bar, FPS display, cross-hairs etc. (anything that will be used in all of the game levels) Moderate to heavy modification should be made here.


CGamePlayStateLevel01

Inherits form CGamePlayState. All level specific code should be added here. Loading level01 map, initialising all level01 objects and models etc. Any number of additional levels can be added in the same way with no overhead. Also each level is totally independent and can be modified/worked-on in complete isolation. Any generic code added to any of it's parents, will automatically become available to all of it's levels. Heavy modification should be made here.

Personal tools