?? cblockpool.h
字號:
#ifndef CBlockPool_h
#define CBlockPool_h
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "CDynamicArray.h"
#include "CPoolCell.h"
#include "Struct.h"
class CGameRender;
/////////////////////////////////////////////////////////////////////////////
//方塊池類,描述下落后的方塊堆。一個二維數組描述方塊池,每個元素是方塊的元素。
//0表示沒有任何方塊
/////////////////////////////////////////////////////////////////////////////
class CBlockPool
{
public:
friend class CGameRender;
CBlockPool();
~CBlockPool();
bool Init( int row, int col );
void Free();
bool ReSet( int row, int col );
bool IsAvailable( int row, int col ); //判斷一個位置是否為空
bool IsAvailable( const POSITION &position )
{ return IsAvailable( position.row, position.col ); }
void SetCell( const POSITION &position,
int iValue ); //設置一個格子
void UpdateHighestLine( int row ); //更新最高行
void CheckFullLine(); //檢測已滿的行
void AdjustPool(); //調整方塊堆
void OnFinishAdjust();
bool IsPoolFull()
{ return m_iHighestLine >= m_iRow - 1; }
private:
int GetNumOfLine( int row ); //獲取一行的方塊數
void ClearLine( int row ); //清空一行
bool GetAdjustBlock(); //獲取邊界方塊
private:
int m_iRow, m_iColumn; //數組的行數,列數
int m_iHighestLine; //方塊堆的最高行
int m_iFirstFullLine; //第一個滿行,為-1時沒有滿行
CDoubleArray<CPoolCell> m_BlockPool; //二維數組的方塊池
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -