📄 gameboard.h
字号:
#ifndef __TETRIS_GAMEBOARD_H__
#define __TETRIS_GAMEBOARD_H__
#include <vector>
#include "dib256.h" // Added by ClassView
using std::vector;
class CPiece;
/////////////////////////////////////////////////////////////////////////////
// CGameBoard window
typedef struct NMBoard_tag {
NMHDR hdr;
UINT level;
UINT lines;
UINT points;
UINT pieces;
} NMBOARD;
typedef struct NMPreview_tag {
NMHDR hdr;
CPiece * piece;
} NMPREVIEW;
#define NMB_PREVIEW (0U-1997U)
#define NMB_GAMEOVER (0U-1998U)
#define NMB_STATISTICS (0U-1999U)
class CGameBoard : public CWnd
{
friend class CTetrisDlg;
friend class COptionsDlg;
DECLARE_DYNAMIC(CGameBoard);
// Construction/Destruction
public:
CGameBoard();
virtual ~CGameBoard();
public:
void StopGame();
void StartGame();
void PauseGame();
void ResumeGame();
void InitBoard();
int Height(LPCRECT pRect = 0) const;
int Width(LPCRECT pRect = 0) const;
void GetDimension(int & uWidth, int & uHeight);
void SetDimension(int uWidth, int uHeight);
void ShowGrid( BOOL bShow = TRUE );
BOOL IsGridEnabled() const { return m_bShowGrid; }
ULONG GetCompleteLines() const { return m_ulCompleteLines; }
USHORT GetLevel() const { return m_usLevel; }
void SetLevel(USHORT usLevel);
ULONG GetPieceCount() const { return m_ulPieces; }
void EnableSound(BOOL bEnable = TRUE);
void EnableMusic(BOOL bEnable = TRUE);
void SetMusicType(UINT uResource);
void UseExFigureSet(BOOL bUse) { m_bExFigures = bUse; }
BOOL UseExFigureSet() const { return m_bExFigures; }
void SetVolume(DWORD dwPercent);
DWORD GetVolume() const { return m_dwVolume; }
void SetMusicFile(const CString &); // name of external music file without path and extension
// path defaults to CGTetris' path and extension to ".mid"
void SetMusicSequence(BOOL bSet);
void MoveLeft();
void MoveRight();
void Rotate();
void BackRotate();
void StartFall();
void StopFall();
protected:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGameBoard)
//}}AFX_VIRTUAL
protected: // member data
vector< vector<COLORREF> > m_Board;
CPiece * m_pCurPiece;
CPiece * m_pNextPiece;
COLORREF m_clrCurPiece;
USHORT m_usLevel;
ULONG m_ulCompleteLines;
ULONG m_ulPieces;
UINT m_uTimer;
UINT m_uPoints;
NMBOARD m_BoardNotifier;
NMPREVIEW m_PreviewNotifier;
DWORD m_dwVolume; // volume of background music
// the lower left corner of the current shape
int m_nCurCol;
int m_nCurLine;
COLORREF m_clrBackground;
int m_nSquareHeight;
int m_nSquareWidth;
BOOL m_bShowGrid;
BOOL m_bExFigures;
BOOL m_bLevelSelected;
COLORREF m_clrTopLeft;
COLORREF m_clrBottomRight;
CString m_strMusicFile; // if music comes from external file
static BOOL m_bRegistered;
static CMusicPlayer * m_pMusicPlayer;
protected:
void ResetTimer(BOOL bSpeed = FALSE);
CPiece * SelectPiece();
void Paint();
void OnLineComplete();
void OnNewPiece();
void OnGameOver();
void CheckBoard();
void FixPiece();
bool CanPlace(int nLine, int nCol);
void NotifyParent(BOOL bStatistics = TRUE); // if FALSE, then send Preview request
static BOOL Register();
// Generated message map functions
//{{AFX_MSG(CGameBoard)
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnNcDestroy();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
LRESULT CALLBACK GameBoardWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
CGameBoard * TetrisGetGameBoard();
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GAMEBOARD_H__35EAD7F1_009B_11D2_A729_000000000000__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -