CEngine.h
上传用户:snevogroup
上传日期:2008-06-06
资源大小:432k
文件大小:3k
源码类别:

Symbian

开发平台:

C/C++

  1. #ifndef __CENGINE_H
  2. #define __CENGINE_H
  3. // INCLUDES
  4. #include <e32base.h>
  5. #include <w32std.h>
  6. #include "MGameTimerObserver.h"
  7. #include "TSample.h"
  8. // forward declarations
  9. class CGameTimer;
  10. class CGameTetris;
  11. class CSplash;
  12. class CMenu;
  13. class TScore;
  14. class CSoundMixer;
  15. const TInt TopNum = 5;
  16. enum TGameState
  17. {
  18. ENewSplash = 0,
  19. EDialog,
  20. EMenu,
  21. EMenuRunning,
  22. ERunning,
  23. EGameOver,
  24. EExit
  25. };
  26. class CEngine : public CBase
  27.               , public MGameTimerObserver
  28. {
  29. // construct and destruct
  30. public:
  31. static CEngine* NewL( CGameTetris* aGame, CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode );
  32. ~CEngine();
  33. private:
  34. void ConstructL();
  35. CEngine( CGameTetris* aGame, CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode );
  36. //////////////////////////////////////////////////////////////////////////////////
  37. // Method from MGameTimerObserver
  38. public:
  39. /// Game timer calls this function
  40. /// @return timer continue flag, 0 if timer is to stop.
  41. TInt DoGameFrameL();
  42. // New Method
  43. void Start();
  44. void Stop();
  45. void Pause();
  46. void Command(TInt aCommand);
  47. private:
  48. TBool ShowSplash();
  49. void DipEffect(TUint16* aAddr, TInt aWidthInPixel, TInt aHeightInPixel);
  50. void DipBlackwhite(TUint16* aAddr, TInt aWidthInPixel, TInt aHeightInPixel);
  51. // method deal with score
  52. void ScoreLoadL();
  53. void ScoreSaveL();
  54. void ScoreAddL();
  55. void ScoreDisplay();
  56. void ScoreReset();
  57. // method deal with sound
  58. void StopMixer();
  59. void StartMixer();
  60. //////////////////////////////////////////////////////////////////////////////////
  61. // data
  62. private:
  63. CSplash* iSplash;
  64. CGameTimer* iTimer; // has a 
  65. CMenu* iMenu; // has a
  66. CGameTetris* iGame;
  67. CWindowGc& iGc;
  68. RWindow& iWindow;
  69. TDisplayMode iDisplayMode;
  70. TRect iDrawRect; // Draw region on screen
  71. TPoint iPos;
  72. TBool iPause;
  73. CFbsBitmap* iBackBufferBitmap;
  74. CFbsBitmapDevice* iBackBufferDevice;
  75. CFbsBitGc* iBackBufferGc;
  76. TBitmapUtil* iBitmapUtil; // Only for bitmap locking
  77. TInt iControl;
  78. // keys
  79. TInt iKey;
  80. TGameState iGameState;
  81. CArrayFixSeg<TScore> *iScoreTable; // score table
  82. TBool iDisplayTop5;
  83. // sound
  84. CSoundMixer* iSound;
  85. TSample iSoundBg; // background music
  86. TSample iSoundGameOver; // sound effect
  87. TSample iSoundOnClick; // sound effect
  88. TSample iSoundMenu;
  89. TSample iSoundClearRow;
  90. TSample iSoundWellDone;
  91. TSample iSoundLevelUp;
  92. TBool iSoundEffectOff;
  93. TBool iMusicOff;
  94. };
  95. #endif