ScummVM API documentation
Game.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_GAME_H
29 #define HPL_GAME_H
30 
31 #include "hpl1/engine/system/SystemTypes.h"
32 
33 namespace hpl {
34 
35 class cUpdater;
36 class LowLevelGameSetup;
37 class LowLevelSystem;
38 class cLogicTimer;
39 
40 class cSystem;
41 class cInput;
42 class cResources;
43 class cGraphics;
44 class cScene;
45 class cSound;
46 class cPhysics;
47 class cAI;
48 class cGui;
49 
50 class cFPSCounter {
51 public:
52  cFPSCounter(LowLevelSystem *apLowLevelSystem);
53 
54  void AddFrame();
55 
56  float mfFPS;
57  float mfUpdateRate;
58 
59 private:
60  LowLevelSystem *mpLowLevelSystem;
61  int mlFramecounter;
62  float mfFrametimestart;
63  float mfFrametime;
64 };
65 
66 //---------------------------------------------------
67 
69 public:
71 
72  void AddString(const tString &asName, const tString &asValue);
73 
74  void AddInt(const tString &asName, int alValue);
75  void AddFloat(const tString &asName, float afValue);
76  void AddBool(const tString &asName, bool abValue);
77 
78  const tString &GetString(const tString &asName);
79 
80  float GetFloat(const tString &asName, float afDefault);
81  int GetInt(const tString &asName, int alDefault);
82  bool GetBool(const tString &asName, bool abDefault);
83 
84 private:
86  tString msBlank;
87 };
88 
89 //---------------------------------------------------
90 
91 class cGame {
92 public:
93  cGame(LowLevelGameSetup *apGameSetup, cSetupVarContainer &aVars);
94  cGame(LowLevelGameSetup *apGameSetup, int alWidth, int alHeight, int alBpp, bool abFullscreen,
95  unsigned int alUpdateRate = 60, int alMultisampling = 0);
96  ~cGame();
97 
98 private:
99  void GameInit(LowLevelGameSetup *apGameSetup, cSetupVarContainer &aVars);
100 
101 public:
105  void Run();
110  void Exit();
111 
116  cScene *GetScene();
121  cResources *GetResources();
122 
127  cUpdater *GetUpdater();
128 
133  cSystem *GetSystem();
134 
139  cInput *GetInput();
140 
145  cGraphics *GetGraphics();
150  cSound *GetSound();
155  cPhysics *GetPhysics();
156 
161  cAI *GetAI();
162 
167  cGui *GetGui();
168 
169  void ResetLogicTimer();
170  void SetUpdatesPerSec(int alUpdatesPerSec);
171  int GetUpdatesPerSec();
172  float GetStepSize();
173 
174  cLogicTimer *GetLogicTimer() { return mpLogicTimer; }
175 
176  float GetFPS();
177 
178  void SetFPSUpdateRate(float afSec);
179  float GetFPSUpdateRate();
180 
181  float GetFrameTime() { return mfFrameTime; }
182 
183  float GetUpdateTime() { return mfUpdateTime; }
184 
185  double GetGameTime() { return mfGameTime; }
186 
187  void SetLimitFPS(bool abX) { mbLimitFPS = abX; }
188  bool GetLimitFPS() { return mbLimitFPS; }
189 
190 private:
191  bool mbGameIsDone;
192 
193  float mfFrameTime;
194 
195  float mfUpdateTime;
196 
197  double mfGameTime;
198 
199  LowLevelGameSetup *mpGameSetup;
200  cUpdater *mpUpdater;
201  cLogicTimer *mpLogicTimer;
202 
203  cFPSCounter *mpFPSCounter;
204 
205  bool mbLimitFPS;
206 
207  // Modules that Game connnect to:
208  cResources *mpResources;
209  cSystem *mpSystem;
210  cInput *mpInput;
211  cGraphics *mpGraphics;
212  cScene *mpScene;
213  cSound *mpSound;
214  cPhysics *mpPhysics;
215  cAI *mpAI;
216  cGui *mpGui;
217 };
218 
219 } // namespace hpl
220 
221 #endif // HPL_GAME_H
Definition: AI.h:36
Definition: Updater.h:46
Definition: Gui.h:73
Definition: Game.h:91
Definition: Game.h:68
Definition: str.h:59
Definition: AI.h:40
Definition: stablemap.h:43
Definition: Sound.h:40
Definition: low_level_game_setup.h:42
Definition: Game.h:50
Definition: Physics.h:67
Definition: Input.h:55
Definition: LogicTimer.h:35
Definition: low_level_system.h:95
Definition: Resources.h:160
Definition: System.h:36
Definition: Scene.h:61
Definition: Graphics.h:46