www.pudn.com > Tetris.rar > CEngine.h


#ifndef __CENGINE_H 
#define __CENGINE_H 
 
 
// INCLUDES 
#include  
#include  
#include "MGameTimerObserver.h" 
 
#include "TSample.h" 
 
// forward declarations 
class CGameTimer; 
class CGameTetris; 
class CSplash; 
class CMenu; 
class TScore; 
class CSoundMixer; 
 
const TInt TopNum = 5; 
 
enum TGameState 
{ 
		ENewSplash = 0, 
		EDialog, 
		EMenu, 
		EMenuRunning, 
		ERunning, 
		EGameOver, 
		EExit 
}; 
 
class CEngine : public CBase 
              , public MGameTimerObserver 
{ 
// construct and destruct 
public: 
 
	static CEngine* NewL( CGameTetris* aGame, CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode ); 
 
	~CEngine(); 
 
private: 
 
	void ConstructL(); 
 
	CEngine( CGameTetris* aGame, CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode ); 
 
////////////////////////////////////////////////////////////////////////////////// 
// Method from MGameTimerObserver 
 
public: 
	/// Game timer calls this function 
	/// @return timer continue flag, 0 if timer is to stop. 
	TInt DoGameFrameL(); 
 
// New Method 
	void Start(); 
	void Stop(); 
	void Pause(); 
 
	void Command(TInt aCommand); 
 
private: 
	TBool ShowSplash(); 
 
	void DipEffect(TUint16* aAddr, TInt aWidthInPixel, TInt aHeightInPixel); 
 
	void DipBlackwhite(TUint16* aAddr, TInt aWidthInPixel, TInt aHeightInPixel); 
 
	// method deal with score 
	void ScoreLoadL(); 
	void ScoreSaveL(); 
	void ScoreAddL(); 
	void ScoreDisplay(); 
	void ScoreReset(); 
 
	// method deal with sound 
	void StopMixer(); 
	void StartMixer(); 
 
////////////////////////////////////////////////////////////////////////////////// 
// data 
 
private: 
	CSplash*		iSplash; 
	CGameTimer*		iTimer;					// has a  
	CMenu*			iMenu;					// has a 
 
	CGameTetris*	iGame; 
	CWindowGc&		iGc; 
	RWindow&		iWindow; 
	TDisplayMode	iDisplayMode; 
 
	TRect			iDrawRect;				// Draw region on screen 
	TPoint			iPos; 
 
 
	TBool			iPause; 
 
	CFbsBitmap*			iBackBufferBitmap; 
	CFbsBitmapDevice*	iBackBufferDevice; 
	CFbsBitGc*			iBackBufferGc; 
 
	TBitmapUtil*		iBitmapUtil;		// Only for bitmap locking 
	TInt				iControl; 
 
	// keys 
	TInt			iKey; 
 
	 
	TGameState			iGameState; 
 
	CArrayFixSeg *iScoreTable;		// score table 
 
	TBool				iDisplayTop5; 
 
	// sound 
	CSoundMixer*	iSound; 
 
	TSample		iSoundBg;			// background music 
	TSample		iSoundGameOver;		// sound effect 
	TSample		iSoundOnClick;		// sound effect 
	TSample		iSoundMenu; 
	TSample		iSoundClearRow; 
	TSample		iSoundWellDone; 
	TSample		iSoundLevelUp; 
 
	TBool		iSoundEffectOff; 
	TBool		iMusicOff; 
}; 
 
 
 
#endif