- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# CGame Class Reference

Game class initialize the game and passes events to submodules. More...

`#include <Game.h>`

Collaboration diagram for CGame:

[legend]

List of all members.

## Public Member Functions
| CGame ()
| ~CGame ()
void | RenderLoading (D3DXVECTOR2 loadingTrans2, WCHAR *strText)
bool | Init (HWND hWnd, int screenWidth, int screenHeight)
bool | OnEvent (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
void | OnRender ()
void | OnFrameMove ()
void | OnResetDevice (HWND hWnd)
void | OnLostDevice ()
bool | LoadSettingsFromFile (HWND hWnd)
void | WriteSettingsToFile ()

## Detailed Description

Game class initialize the game and passes events to submodules.

This class is topmost game class that separates game modes and passes info to appropriate game modules. Global game variables and utility functions are stored in this class, all game modules (Menu, Movie, Level) are initialized and called from from CGame class.

Author:
  Petar Bajic

Date:
  January, 16 2007.

## Constructor & Destructor Documentation

CGame::CGame | ( |  | ) |

Standard constructor. Game varibles are initialized to 0. To see real initialization, see CGame::Init() function.

CGame::~CGame | ( |  | ) |

Standard Destructor All that is created (alocated) in Init should be released here.

## Member Function Documentation

void CGame::RenderLoading | ( | D3DXVECTOR2 | loadingTrans2,
|  | WCHAR * | strText |
| ) |  |  |

Render Loading Picture. When user starts the game, loading screen is displayed because it takes time to load all models. Sheep is being 'filled' while loading.

bool CGame::Init | ( | HWND | hWnd,
|  | int | screenWidth,
|  | int | screenHeight |
| ) |  |  |

Init function loads all game elements (models, music, textures...) and sets default parameters. It calls init functions of all game modes like CMenu::Init() and CLevel::Init(), sending them various environment parameters and 'global' game variables.

bool CGame::OnEvent | ( | HWND | hWnd,
|  | UINT | msg,
|  | WPARAM | wParam,
|  | LPARAM | lParam |
| ) |  |  |

On Event function catch events like mouse click and keyboard input. It takes care of resizing game window. It passes events to appropriate game mode.

void CGame::OnRender | ( |  | ) |

Render function checks wich game mode is active. If Menu is on, it calls CMenu::Render(), etc.

void CGame::OnFrameMove | ( |  | ) |

OnFrameMove Function is called before render function to calculate position of all objects in that moment. It moves all animated object by little bit depending on m_CurrentTime and m_elapsedTime game variables.

This function checks game mode, and calculates move only for the active mode.

void CGame::OnResetDevice | ( | HWND | hWnd | ) |

Standard DirectX functionality. It must be called when something big changes with the display, like switching to fullscreen mode. First is called OnLostDevice, then OnResetDevice.

void CGame::OnLostDevice | ( |  | ) |

Standard DirectX functionality. It must be called when something big changes with the display, like switching to fullscreen mode. First is called OnLostDevice, then OnResetDevice.

bool CGame::LoadSettingsFromFile | ( | HWND | hWnd | ) |

Load data from config.ini file. When game is started, settings like fullscreen, dificulty and details are loaded.

void CGame::WriteSettingsToFile | ( |  | ) |

Write settings to ini file. On game exit, active settings are being written to config.ini file. These include Fullscreen mode, dificulty, details, etc.

The documentation for this class was generated from the following files:

- My Documents/TS2/inc/Game.h
- My Documents/TS2/src/Game.cpp