CGameTetris.h
上传用户:snevogroup
上传日期:2008-06-06
资源大小:432k
文件大小:2k
- #ifndef __CGAMETETRIS_H
- #define __CGAMETETRIS_H
- #include <w32std.h>
- #include "TGrid.h"
- #include "TBlock.h"
- const TUint8 COLORNUM = 9;
- class CGameTetris : public CBase
- {
- // construct and destruct
- public:
- static CGameTetris* NewL();
- ~CGameTetris();
- private:
- void ConstructL();
- CGameTetris();
- ///////////////////////////////////////////////////////////////////////////////
- // method
- public:
- TBool Command(TInt aCommand);
- void Draw(CFbsBitGc* aBackBufferGc);
- TInt8 Run();
- // Other Method
- private:
- void LoadResL();
- TBool MoveTo(const TPoint& aNewPos);
- void Rotate();
- // create a new block
- void NewBlock();
- // Start a new game
- void StartNewGame();
- //
- TBool IsBlock(const TPoint& aPos) const;
- // Get a row from Grid
- void GetRowContent(TUint8 aRow, TFixedArray<TUint8, KGridX>& aRowContent);
- // check if a row is full
- TInt CheckRows();
- // start lines
- void StartLines(TUint8 aLines);
- // calculate score
- void Calculate(TInt rows);
- TBool FixBlock();
- ///////////////////////////////////////////////////////////////////////////////
- // Data
- private:
- TFixedArray<CFbsBitmap*, COLORNUM> iBmpBlock;
- CFbsBitmap* iBmpBackground;
- TGrid iGrid;
- TBlock iBlock;
- TBlock iBlockNext;
- TPoint iBlockPos;
- TInt64 iSeed;
- TInt iDelay;
- TInt iLine;
- TInt iLevel;
- public:
- // Game State
- TInt iStateScore;
- TUint8 iStateDifficulty; // 0 or 1 or other num
- TInt8 iStateRotateDir; // 1 or -1
- TBool iStateRunning;
- TBool iStateLevelUp;
- TBool iStateWellDone;
- TBool iStateClearRow;
- TUint8 iStateStartLines;
- };
- #endif