Game.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. #ifndef GAME_H_
  2. #define GAME_H_
  3. #include "Keyboard.h"
  4. #include "Mouse.h"
  5. #include "Touch.h"
  6. #include "Gesture.h"
  7. #include "Gamepad.h"
  8. #include "AudioController.h"
  9. #include "AnimationController.h"
  10. #include "PhysicsController.h"
  11. #include "SocialController.h"
  12. #include "AIController.h"
  13. #include "AudioListener.h"
  14. #include "Rectangle.h"
  15. #include "Vector4.h"
  16. #include "TimeListener.h"
  17. namespace gameplay
  18. {
  19. class ScriptController;
  20. /**
  21. * Defines the basic game initialization, logic and platform delegates.
  22. */
  23. class Game
  24. {
  25. friend class Platform;
  26. friend class ShutdownListener;
  27. public:
  28. /**
  29. * The game states.
  30. */
  31. enum State
  32. {
  33. UNINITIALIZED,
  34. RUNNING,
  35. PAUSED
  36. };
  37. /**
  38. * Flags used when clearing the active frame buffer targets.
  39. */
  40. enum ClearFlags
  41. {
  42. CLEAR_COLOR = GL_COLOR_BUFFER_BIT,
  43. CLEAR_DEPTH = GL_DEPTH_BUFFER_BIT,
  44. CLEAR_STENCIL = GL_STENCIL_BUFFER_BIT,
  45. CLEAR_COLOR_DEPTH = CLEAR_COLOR | CLEAR_DEPTH,
  46. CLEAR_COLOR_STENCIL = CLEAR_COLOR | CLEAR_STENCIL,
  47. CLEAR_DEPTH_STENCIL = CLEAR_DEPTH | CLEAR_STENCIL,
  48. CLEAR_COLOR_DEPTH_STENCIL = CLEAR_COLOR | CLEAR_DEPTH | CLEAR_STENCIL
  49. };
  50. /**
  51. * Destructor.
  52. */
  53. virtual ~Game();
  54. /**
  55. * Gets the single instance of the game.
  56. *
  57. * @return The single instance of the game.
  58. */
  59. static Game* getInstance();
  60. /**
  61. * Gets whether vertical sync is enabled for the game display.
  62. *
  63. * @return true if vsync is enabled; false if not.
  64. */
  65. static bool isVsync();
  66. /**
  67. * Sets whether vertical sync is enabled for the game display.
  68. *
  69. * @param enable true if vsync is enabled; false if not.
  70. */
  71. static void setVsync(bool enable);
  72. /**
  73. * Gets the total absolute running time (in milliseconds) since Game::run().
  74. *
  75. * @return The total absolute running time (in milliseconds).
  76. */
  77. static double getAbsoluteTime();
  78. /**
  79. * Gets the total game time (in milliseconds). This is the total accumulated game time (unpaused).
  80. *
  81. * You would typically use things in your game that you want to stop when the game is paused.
  82. * This includes things such as game physics and animation.
  83. *
  84. * @return The total game time (in milliseconds).
  85. */
  86. static double getGameTime();
  87. /**
  88. * Gets the game state.
  89. *
  90. * @return The current game state.
  91. */
  92. inline State getState() const;
  93. /**
  94. * Determines if the game has been initialized.
  95. *
  96. * @return true if the game initialization has completed, false otherwise.
  97. */
  98. inline bool isInitialized() const;
  99. /**
  100. * Returns the game configuration object.
  101. *
  102. * This method returns a Properties object containing the contents
  103. * of the game.config file.
  104. *
  105. * @return The game configuration Properties object.
  106. */
  107. Properties* getConfig() const;
  108. /**
  109. * Called to initialize the game, and begin running the game.
  110. *
  111. * @return Zero for normal termination, or non-zero if an error occurred.
  112. */
  113. int run();
  114. /**
  115. * Pauses the game after being run.
  116. */
  117. void pause();
  118. /**
  119. * Resumes the game after being paused.
  120. */
  121. void resume();
  122. /**
  123. * Exits the game.
  124. */
  125. void exit();
  126. /**
  127. * Platform frame delegate.
  128. *
  129. * This is called every frame from the platform.
  130. * This in turn calls back on the user implemented game methods: update() then render()
  131. */
  132. void frame();
  133. /**
  134. * Gets the current frame rate.
  135. *
  136. * @return The current frame rate.
  137. */
  138. inline unsigned int getFrameRate() const;
  139. /**
  140. * Gets the game window width.
  141. *
  142. * @return The game window width.
  143. */
  144. inline unsigned int getWidth() const;
  145. /**
  146. * Gets the game window height.
  147. *
  148. * @return The game window height.
  149. */
  150. inline unsigned int getHeight() const;
  151. /**
  152. * Gets the aspect ratio of the window. (width / height)
  153. *
  154. * @return The aspect ratio of the window.
  155. */
  156. inline float getAspectRatio() const;
  157. /**
  158. * Gets the game current viewport.
  159. *
  160. * The default viewport is Rectangle(0, 0, Game::getWidth(), Game::getHeight()).
  161. */
  162. inline const Rectangle& getViewport() const;
  163. /**
  164. * Sets the game current viewport.
  165. *
  166. * The x, y, width and height of the viewport must all be positive.
  167. *
  168. * viewport The custom viewport to be set on the game.
  169. */
  170. void setViewport(const Rectangle& viewport);
  171. /**
  172. * Clears the specified resource buffers to the specified clear values.
  173. *
  174. * @param flags The flags indicating which buffers to be cleared.
  175. * @param clearColor The color value to clear to when the flags includes the color buffer.
  176. * @param clearDepth The depth value to clear to when the flags includes the color buffer.
  177. * @param clearStencil The stencil value to clear to when the flags includes the color buffer.
  178. */
  179. void clear(ClearFlags flags, const Vector4& clearColor, float clearDepth, int clearStencil);
  180. /**
  181. * Clears the specified resource buffers to the specified clear values.
  182. *
  183. * @param flags The flags indicating which buffers to be cleared.
  184. * @param red The red channel.
  185. * @param green The green channel.
  186. * @param blue The blue channel.
  187. * @param alpha The alpha channel.
  188. * @param clearDepth The depth value to clear to when the flags includes the color buffer.
  189. * @param clearStencil The stencil value to clear to when the flags includes the color buffer.
  190. */
  191. void clear(ClearFlags flags, float red, float green, float blue, float alpha, float clearDepth, int clearStencil);
  192. /**
  193. * Gets the audio controller for managing control of audio
  194. * associated with the game.
  195. *
  196. * @return The audio controller for this game.
  197. */
  198. inline AudioController* getAudioController() const;
  199. /**
  200. * Gets the animation controller for managing control of animations
  201. * associated with the game.
  202. *
  203. * @return The animation controller for this game.
  204. */
  205. inline AnimationController* getAnimationController() const;
  206. /**
  207. * Gets the physics controller for managing control of physics
  208. * associated with the game.
  209. *
  210. * @return The physics controller for this game.
  211. */
  212. inline PhysicsController* getPhysicsController() const;
  213. /**
  214. * Gets the AI controller for managing control of artificial
  215. * intelligence associated with the game.
  216. *
  217. * @return The AI controller for this game.
  218. */
  219. inline AIController* getAIController() const;
  220. /**
  221. * Gets the script controller for managing control of Lua scripts
  222. * associated with the game.
  223. *
  224. * @return The script controller for this game.
  225. */
  226. inline ScriptController* getScriptController() const;
  227. /**
  228. * Gets the social controller for managing control of social apis
  229. * associated with the game.
  230. *
  231. * @return The script controller for this game.
  232. *
  233. * @script{ignore}
  234. */
  235. inline SocialController* getSocialController() const;
  236. /**
  237. * Gets the audio listener for 3D audio.
  238. *
  239. * @return The audio listener for this game.
  240. */
  241. AudioListener* getAudioListener();
  242. /**
  243. * Shows or hides the virtual keyboard (if supported).
  244. *
  245. * @param display true when virtual keyboard needs to be displayed; false otherwise.
  246. */
  247. inline void displayKeyboard(bool display);
  248. /**
  249. * Keyboard callback on keyPress events.
  250. *
  251. * @param evt The key event that occurred.
  252. * @param key If evt is KEY_PRESS or KEY_RELEASE then key is the key code from Keyboard::Key.
  253. * If evt is KEY_CHAR then key is the unicode value of the character.
  254. *
  255. * @see Keyboard::KeyEvent
  256. * @see Keyboard::Key
  257. */
  258. virtual void keyEvent(Keyboard::KeyEvent evt, int key);
  259. /**
  260. * Touch callback on touch events.
  261. *
  262. * @param evt The touch event that occurred.
  263. * @param x The x position of the touch in pixels. Left edge is zero.
  264. * @param y The y position of the touch in pixels. Top edge is zero.
  265. * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
  266. *
  267. * @see Touch::TouchEvent
  268. */
  269. virtual void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
  270. /**
  271. * Mouse callback on mouse events. If the game does not consume the mouse move event or left mouse click event
  272. * then it is interpreted as a touch event instead.
  273. *
  274. * @param evt The mouse event that occurred.
  275. * @param x The x position of the mouse in pixels. Left edge is zero.
  276. * @param y The y position of the mouse in pixels. Top edge is zero.
  277. * @param wheelDelta The number of mouse wheel ticks. Positive is up (forward), negative is down (backward).
  278. *
  279. * @return True if the mouse event is consumed or false if it is not consumed.
  280. *
  281. * @see Mouse::MouseEvent
  282. */
  283. virtual bool mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
  284. /**
  285. * Called when the game window has been resized.
  286. *
  287. * This method is called once the game window is created with its initial size
  288. * and then again any time the game window changes size.
  289. *
  290. * @param width The new game window width.
  291. * @param height The new game window height.
  292. */
  293. virtual void resizeEvent(unsigned int width, unsigned int height);
  294. /**
  295. * Gets whether the current platform supports mouse input.
  296. *
  297. * @return true if a mouse is supported, false otherwise.
  298. */
  299. inline bool hasMouse();
  300. /**
  301. * Gets whether mouse input is currently captured.
  302. *
  303. * @return is the mouse captured.
  304. */
  305. inline bool isMouseCaptured();
  306. /**
  307. * Enables or disables mouse capture.
  308. *
  309. * On platforms that support a mouse, when mouse capture is enabled,
  310. * the platform cursor will be hidden and the mouse will be warped
  311. * to the center of the screen. While mouse capture is enabled,
  312. * all mouse move events will then be delivered as deltas instead
  313. * of absolute positions.
  314. *
  315. * @param captured true to enable mouse capture mode, false to disable it.
  316. */
  317. inline void setMouseCaptured(bool captured);
  318. /**
  319. * Sets the visibility of the platform cursor.
  320. *
  321. * @param visible true to show the platform cursor, false to hide it.
  322. */
  323. inline void setCursorVisible(bool visible);
  324. /**
  325. * Determines whether the platform cursor is currently visible.
  326. *
  327. * @return true if the platform cursor is visible, false otherwise.
  328. */
  329. inline bool isCursorVisible();
  330. /**
  331. * Determines whether a specified gesture event is supported.
  332. *
  333. * Use Gesture::GESTURE_ANY_SUPPORTED to test if one or more gesture events are supported.
  334. *
  335. * @param evt The gesture event to test and see if it is supported.
  336. * @return true if the gesture tested is supported; false if not supported.
  337. */
  338. bool isGestureSupported(Gesture::GestureEvent evt);
  339. /**
  340. * Requests the game to register and start recognizing the specified gesture event.
  341. *
  342. * Call with Gesture::GESTURE_ANY_SUPPORTED to recognize all supported gestures.
  343. * Once a gesture is recognized the specific gesture event methods will
  344. * begin to be called.
  345. *
  346. * Registering for:
  347. *
  348. * Gesture::GESTURE_SWIPE calls gestureSwipeEvent(..)
  349. * Gesture::GESTURE_PINCH calls gesturePinchEvent(..)
  350. * Gesture::GESTURE_TAP calls gestureTapEvent(..)
  351. *
  352. * @param evt The gesture event to start recognizing for
  353. */
  354. void registerGesture(Gesture::GestureEvent evt);
  355. /**
  356. * Requests the game to unregister for and stop recognizing the specified gesture event.
  357. *
  358. * Call with Gesture::GESTURE_ANY_SUPPORTED to unregister events from all supported gestures.
  359. *
  360. * @param evt The gesture event to start recognizing for
  361. */
  362. void unregisterGesture(Gesture::GestureEvent evt);
  363. /**
  364. * Determines whether a specified gesture event is registered to receive event callbacks.
  365. *
  366. * @return true if the specified gesture event is registered; false of not registered.
  367. */
  368. bool isGestureRegistered(Gesture::GestureEvent evt);
  369. /**
  370. * Gesture callback on Gesture::SWIPE events.
  371. *
  372. * @param x The x-coordinate of the start of the swipe.
  373. * @param y The y-coordinate of the start of the swipe.
  374. * @param direction The direction of the swipe
  375. *
  376. * @see Gesture::SWIPE_DIRECTION_UP
  377. * @see Gesture::SWIPE_DIRECTION_DOWN
  378. * @see Gesture::SWIPE_DIRECTION_LEFT
  379. * @see Gesture::SWIPE_DIRECTION_RIGHT
  380. */
  381. virtual void gestureSwipeEvent(int x, int y, int direction);
  382. /**
  383. * Gesture callback on Gesture::PINCH events.
  384. *
  385. * @param x The centroid x-coordinate of the pinch.
  386. * @param y The centroid y-coordinate of the pinch.
  387. * @param scale The scale of the pinch.
  388. */
  389. virtual void gesturePinchEvent(int x, int y, float scale);
  390. /**
  391. * Gesture callback on Gesture::TAP events.
  392. *
  393. * @param x The x-coordinate of the tap.
  394. * @param y The y-coordinate of the tap.
  395. */
  396. virtual void gestureTapEvent(int x, int y);
  397. /**
  398. * Gamepad callback on gamepad events. Override to receive Gamepad::CONNECTED_EVENT
  399. * and Gamepad::DISCONNECTED_EVENT, and store the Gamepad* in order to poll it from update().
  400. *
  401. * @param evt The gamepad event that occurred.
  402. * @param gamepad The gamepad that generated the event.
  403. */
  404. virtual void gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad);
  405. /**
  406. * Gets the current number of gamepads currently connected to the system.
  407. *
  408. * @return The number of gamepads currently connected to the system.
  409. */
  410. inline unsigned int getGamepadCount() const;
  411. /**
  412. * Gets the gamepad at the specified index.
  413. *
  414. * The gamepad index can change when connected and disconnected so you
  415. * cannot rely on this other than iterating through them all to display
  416. * them or poll them.
  417. *
  418. * The preferPhysical will bump over virtual gamepads if physical gamepads are
  419. * connected and return the request index of the first or second physcial and then
  420. * return back to the first virtual after.
  421. *
  422. * @param index The index of the gamepad to retrieve.
  423. * @param preferPhysical true if you prefer return a physical if exist; false if only virtual.
  424. * @return The gamepad at the specified index.
  425. */
  426. inline Gamepad* getGamepad(unsigned int index, bool preferPhysical = true) const;
  427. /**
  428. * Sets whether multi-sampling is to be enabled/disabled. Default is disabled.
  429. *
  430. * @param enabled true sets multi-sampling to be enabled, false to be disabled.
  431. */
  432. inline void setMultiSampling(bool enabled);
  433. /*
  434. * Is multi-sampling enabled.
  435. *
  436. * @return true if multi-sampling is enabled.
  437. */
  438. inline bool isMultiSampling() const;
  439. /**
  440. * Sets multi-touch is to be enabled/disabled. Default is disabled.
  441. *
  442. * @param enabled true sets multi-touch is enabled, false to be disabled.
  443. */
  444. inline void setMultiTouch(bool enabled);
  445. /**
  446. * Is multi-touch mode enabled.
  447. *
  448. * @return true if multi-touch is enabled.
  449. */
  450. inline bool isMultiTouch() const;
  451. /**
  452. * Whether this game is allowed to exit programmatically.
  453. *
  454. * @return true if a programmatic exit is allowed.
  455. */
  456. inline bool canExit() const;
  457. /**
  458. * Whether this game has accelerometer support.
  459. */
  460. inline bool hasAccelerometer() const;
  461. /**
  462. * Gets the current accelerometer values for use as an indication of device
  463. * orientation. Despite its name, implementations are at liberty to combine
  464. * accelerometer data with data from other sensors as well, such as the gyros.
  465. * This method is best used to obtain an indication of device orientation; it
  466. * does not necessarily distinguish between acceleration and rotation rate.
  467. *
  468. * @param pitch The pitch angle returned (in degrees). Zero if hasAccelerometer() returns false.
  469. * @param roll The roll angle returned (in degrees). Zero if hasAccelerometer() returns false.
  470. */
  471. inline void getAccelerometerValues(float* pitch, float* roll);
  472. /**
  473. * Gets sensor values (raw), if equipped, allowing a distinction between device acceleration
  474. * and rotation rate. Returns zeros on platforms with no corresponding support. See also
  475. * hasAccelerometer() and getAccelerometerValues().
  476. *
  477. * @param accelX The x-coordinate of the raw accelerometer data.
  478. * @param accelY The y-coordinate of the raw accelerometer data.
  479. * @param accelZ The z-coordinate of the raw accelerometer data.
  480. * @param gyroX The x-coordinate of the raw gyroscope data.
  481. * @param gyroY The y-coordinate of the raw gyroscope data.
  482. * @param gyroZ The z-coordinate of the raw gyroscope data.
  483. */
  484. inline void getSensorValues(float* accelX, float* accelY, float* accelZ, float* gyroX, float* gyroY, float* gyroZ);
  485. /**
  486. * Gets the command line arguments.
  487. *
  488. * @param argc The number of command line arguments.
  489. * @param argv The array of command line arguments.
  490. * @script{ignore}
  491. */
  492. void getArguments(int* argc, char*** argv) const;
  493. /**
  494. * Schedules a time event to be sent to the given TimeListener a given number of game milliseconds from now.
  495. * Game time stops while the game is paused. A time offset of zero will fire the time event in the next frame.
  496. *
  497. * @param timeOffset The number of game milliseconds in the future to schedule the event to be fired.
  498. * @param timeListener The TimeListener that will receive the event.
  499. * @param cookie The cookie data that the time event will contain.
  500. * @script{ignore}
  501. */
  502. void schedule(float timeOffset, TimeListener* timeListener, void* cookie = 0);
  503. /**
  504. * Schedules a time event to be sent to the given TimeListener a given number of game milliseconds from now.
  505. * Game time stops while the game is paused. A time offset of zero will fire the time event in the next frame.
  506. *
  507. * Note: the given Lua function must take a single floating point number, which is the difference between the
  508. * current game time and the target time (see TimeListener::timeEvent).
  509. *
  510. * @param timeOffset The number of game milliseconds in the future to schedule the event to be fired.
  511. * @param function The Lua script function that will receive the event.
  512. */
  513. void schedule(float timeOffset, const char* function);
  514. /**
  515. * Opens an URL in an external browser, if available.
  516. *
  517. * @param url URL to be opened.
  518. *
  519. * @return True if URL was opened successfully, false otherwise.
  520. */
  521. bool launchURL(const char *url) const;
  522. protected:
  523. /**
  524. * Constructor.
  525. */
  526. Game();
  527. /**
  528. * Initialize callback that is called just before the first frame when the game starts.
  529. */
  530. virtual void initialize() = 0;
  531. /**
  532. * Finalize callback that is called when the game on exits.
  533. */
  534. virtual void finalize() = 0;
  535. /**
  536. * Update callback for handling update routines.
  537. *
  538. * Called just before render, once per frame when game is running.
  539. * Ideal for non-render code and game logic such as input and animation.
  540. *
  541. * @param elapsedTime The elapsed game time.
  542. */
  543. virtual void update(float elapsedTime) = 0;
  544. /**
  545. * Render callback for handling rendering routines.
  546. *
  547. * Called just after update, once per frame when game is running.
  548. * Ideal for all rendering code.
  549. *
  550. * @param elapsedTime The elapsed game time.
  551. */
  552. virtual void render(float elapsedTime) = 0;
  553. /**
  554. * Renders a single frame once and then swaps it to the display.
  555. *
  556. * This is useful for rendering splash screens.
  557. */
  558. template <class T>
  559. void renderOnce(T* instance, void (T::*method)(void*), void* cookie);
  560. /**
  561. * Renders a single frame once and then swaps it to the display.
  562. * This calls the given Lua function, which should take no parameters and return nothing (void).
  563. *
  564. * This is useful for rendering splash screens.
  565. */
  566. void renderOnce(const char* function);
  567. /**
  568. * Updates the game's internal systems (audio, animation, physics) once.
  569. *
  570. * Note: This does not call the user-defined Game::update() function.
  571. *
  572. * This is useful for rendering animated splash screens.
  573. */
  574. void updateOnce();
  575. private:
  576. /**
  577. * Allows time listener interaction from Lua scripts.
  578. */
  579. struct ScriptListener : public TimeListener
  580. {
  581. /**
  582. * Constructor.
  583. */
  584. ScriptListener(const char* url);
  585. /**
  586. * @see TimeListener#timeEvent(long, void*)
  587. */
  588. void timeEvent(long timeDiff, void* cookie);
  589. /** Holds the name of the Lua script function to call back. */
  590. std::string function;
  591. };
  592. struct ShutdownListener : public TimeListener
  593. {
  594. void timeEvent(long timeDiff, void* cookie);
  595. };
  596. /**
  597. * TimeEvent represents the event that is sent to TimeListeners as a result of calling Game::schedule().
  598. */
  599. class TimeEvent
  600. {
  601. public:
  602. TimeEvent(double time, TimeListener* timeListener, void* cookie);
  603. bool operator<(const TimeEvent& v) const;
  604. double time;
  605. TimeListener* listener;
  606. void* cookie;
  607. };
  608. /**
  609. * Constructor.
  610. *
  611. * @param copy The game to copy.
  612. */
  613. Game(const Game& copy);
  614. /**
  615. * Starts the game.
  616. */
  617. bool startup();
  618. /**
  619. * Shuts down the game.
  620. */
  621. void shutdown();
  622. /**
  623. * Fires the time events that were scheduled to be called.
  624. *
  625. * @param frameTime The current game frame time. Used to determine which time events need to be fired.
  626. */
  627. void fireTimeEvents(double frameTime);
  628. /**
  629. * Loads the game configuration.
  630. */
  631. void loadConfig();
  632. /**
  633. * Loads the gamepads from the configuration file.
  634. */
  635. void loadGamepads();
  636. bool _initialized; // If game has initialized yet.
  637. State _state; // The game state.
  638. unsigned int _pausedCount; // Number of times pause() has been called.
  639. static double _pausedTimeLast; // The last time paused.
  640. static double _pausedTimeTotal; // The total time paused.
  641. double _frameLastFPS; // The last time the frame count was updated.
  642. unsigned int _frameCount; // The current frame count.
  643. unsigned int _frameRate; // The current frame rate.
  644. unsigned int _width; // The game's display width.
  645. unsigned int _height; // The game's display height.
  646. Rectangle _viewport; // the games's current viewport.
  647. Vector4 _clearColor; // The clear color value last used for clearing the color buffer.
  648. float _clearDepth; // The clear depth value last used for clearing the depth buffer.
  649. int _clearStencil; // The clear stencil value last used for clearing the stencil buffer.
  650. Properties* _properties; // Game configuration properties object.
  651. AnimationController* _animationController; // Controls the scheduling and running of animations.
  652. AudioController* _audioController; // Controls audio sources that are playing in the game.
  653. PhysicsController* _physicsController; // Controls the simulation of a physics scene and entities.
  654. AIController* _aiController; // Controls AI simulation.
  655. AudioListener* _audioListener; // The audio listener in 3D space.
  656. std::priority_queue<TimeEvent, std::vector<TimeEvent>, std::less<TimeEvent> >* _timeEvents; // Contains the scheduled time events.
  657. ScriptController* _scriptController; // Controls the scripting engine.
  658. SocialController* _socialController; // Controls social aspect of the game.
  659. std::vector<ScriptListener*>* _scriptListeners; // Lua script listeners.
  660. // Note: Do not add STL object member variables on the stack; this will cause false memory leaks to be reported.
  661. friend class ScreenDisplayer;
  662. };
  663. }
  664. #include "Game.inl"
  665. #endif