GameEngine.h
上传用户:ghyvgy
上传日期:2009-05-26
资源大小:547k
文件大小:3k
源码类别:

其他游戏

开发平台:

Python

  1. /*
  2. s_p_oneil@hotmail.com
  3. Copyright (c) 2000, Sean O'Neil
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions are met:
  7. * Redistributions of source code must retain the above copyright notice,
  8.   this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright notice,
  10.   this list of conditions and the following disclaimer in the documentation
  11.   and/or other materials provided with the distribution.
  12. * Neither the name of this project nor the names of its contributors
  13.   may be used to endorse or promote products derived from this software
  14.   without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  19. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef __GameEngine_h__
  28. #define __GameEngine_h__
  29. #include "DXUtil.h"
  30. #include "Texture.h"
  31. #include "Font.h"
  32. #include "ROAMSphere.h"
  33. #include "StarSystem.h"
  34. /****************************************************************************
  35. * Class: CGameEngine
  36. *****************************************************************************
  37. * This class implements the main engine. For now it just renders each frame. 
  38. * It should eventually handle all logic for determining what happens each
  39. * frame. This includes handling input, updating game objects, playing sounds,
  40. * and rendering the frames.
  41. ****************************************************************************/
  42. class CGameEngine : public IKeyboardListener, IMouseListener
  43. {
  44. protected:
  45. CInputEngine m_engInput;
  46. CFont m_fFont;
  47. C3DObject m_3DCamera;
  48. CStarSystem m_starSystem;
  49. GLenum m_nPolygonMode;
  50. bool m_bTexture;
  51. bool m_bUpdate;
  52. bool m_bInfo;
  53. float m_fMaxError;
  54. public:
  55. CGameEngine();
  56. ~CGameEngine();
  57. void RenderFrame(int nMilliseconds);
  58. void Pause() { m_engInput.Pause(); }
  59. void Restore() { m_engInput.Restore(); }
  60. void HandleInput(float fSeconds);
  61. void TogglePolygonMode()
  62. {
  63. m_nPolygonMode = (m_nPolygonMode == GL_FILL) ? GL_LINE : GL_FILL;
  64. //glPolygonMode(GL_FRONT, m_nPolygonMode);
  65. }
  66. void ToggleTextures() { m_bTexture = !m_bTexture; }
  67. void ToggleInfo() { m_bInfo = !m_bInfo; }
  68. void ToggleUpdate() { m_bUpdate = !m_bUpdate; }
  69. virtual void OnKeyDown(int nKey);
  70. virtual void OnKeyUp(int nKey);
  71. virtual void OnMouseButtonDown(int nButton);
  72. virtual void OnMouseButtonUp(int nButton);
  73. };
  74. #endif // __GameEngine_h__