⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwrectview.h

📁 小游戏:俄罗斯方块:)
💻 H
字号:
// HWRECTView.h : interface of the CHWRECTView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_HWRECTVIEW_H__8B080E4F_DF7E_11D2_A2DF_00A0248D3AC7__INCLUDED_)
#define AFX_HWRECTVIEW_H__8B080E4F_DF7E_11D2_A2DF_00A0248D3AC7__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

// 宏变量:白色和黑色
#define WHITE RGB(255,255,255)
#define BLACK RGB(0,0,0)
#define BLUE RGB(0,0,255)

//下降,左移,右移宏定义
#define LEFT 0
#define RIGHT 1
#define UP 2
#define DOWN 3


class CHWRECTView : public CView
{
protected: // create from serialization only
	CHWRECTView();
	DECLARE_DYNCREATE(CHWRECTView)

// Attributes
public:
	CHWRECTDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CHWRECTView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CHWRECTView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	//列与行的数量
	int m_iCol;
	int m_iRow;

	//小方块的大小,它会随着行与列的不同而不同,具体为:
	// 12行10列,30个象素的正方形
	// 18行15列,20
	// 24行20列,15
	// 30行25列,12
	int m_iLarge;

	//当前的级别,换算成速度的算法为:1500 - m_iLevel*200
	int m_iLevel;

	//游戏区域左上角的坐标
	int m_iStartX;
	int m_iStartY;

	void RectChange();
	BOOL RightIsLimit();
	BOOL LeftIsLimit();
	//各种不同形状方块的接触面,接触面是指这样的小方块:它下面如果有另外的方块则表示
	//此方块已到底。
	//此数组记录了这些接触面在当前方块动态位置数组中的元素号
	int InterFace[74][4];
	
	//当前的方块形状
	int m_currentRect;

	//判断当前方块是否到底
	void ActiveIsBottom();
	
	//当前方块下降
	void RectDown();

	//当前方块加速:UP,左移:LEFT,右移:RIGHT
	void RectArrow(int m_Type);
	
	//将一方块初始样式数据赋给当前方块动态位置数组以及下一次将要出来的方块的位置数组
	void RectStatusToActiveStatus(int m_which);
	void RectStatusToNextStatus(int m_which);
	
	void ActiveStatusToGameStatus();
	int Random(int MaxNumber);
	//标识方块已到底的变量,到底为TRUE
	BOOL m_isBottom;

	//用于标志方块状态的数组,大小由横格与竖格数据决定,为1表示该方块显示,或者不显示
	//画形状只需要修改数组中相应元素的状态值即可
	//由时钟控制,定时在OnPaint函数中根据数组画方块
	int GameStatus[100][100];

	//用于保存当前方块的动态位置,4个小方块分别在大数组中的位置
	//存放位置为先左后右,每一列又遵循先上后下的原则
	int ActiveStatus[4][2];

	//存入下一次要出来的方块的模样的数组
	int NextStatus[4][2];

// Generated message map functions
protected:
	BOOL m_bGamePaush;
	void StopMid();
	void PlayMid();
	void CurrentAreaAndLevel();
	//用于记录当前区域大小与当前级别的字符串,用于显示在屏幕上提示用户当前状态
	CString m_strArea;
	CString m_strLevel;

	//当前的样式与下一个将会出现的样式
	int m_icurrentStatus;
	int m_inextStatus;

	//OnDraw中需要用到的设备名称
	CPen *whitePen;
	CPen *blackPen;
	CBrush *blueBrush,*grayBrush,*blackBrush;

	//是否画网格线
	BOOL m_bDrawGrid;

	//是否插放背景音乐
	BOOL m_bMusic;

	//游戏总成绩
	int m_iPerformance;

	//游戏是否已结束,为FALSE表示开始,否则为结束
	BOOL m_bGameEnd;
	
	//刷新指定的区域,它的大小为:四个小方块所在的正方形的大小
	void InvalidateCurrent();
	//{{AFX_MSG(CHWRECTView)
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnGameStart();
	afx_msg void OnGameEnd();
	afx_msg void OnGameOption();
	afx_msg void OnUpdateGameStart(CCmdUI* pCmdUI);
	afx_msg void OnUpdateGameOption(CCmdUI* pCmdUI);
	afx_msg void OnUpdateGameEnd(CCmdUI* pCmdUI);
	afx_msg void OnUpdateGameExit(CCmdUI* pCmdUI);
	afx_msg void OnUpdateHelpAbout(CCmdUI* pCmdUI);
	afx_msg void OnUpdateHelpHelp(CCmdUI* pCmdUI);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnHelpHelp();
	afx_msg void OnUpdateOptionArea1(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionArea2(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionArea3(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionArea4(CCmdUI* pCmdUI);
	afx_msg void OnOptionArea1();
	afx_msg void OnOptionArea2();
	afx_msg void OnOptionArea3();
	afx_msg void OnOptionArea4();
	afx_msg void OnUpdateOptionLevel1(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionLevel2(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionLevel3(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionLevel4(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionLevel5(CCmdUI* pCmdUI);
	afx_msg void OnUpdateOptionLevel6(CCmdUI* pCmdUI);
	afx_msg void OnOptionLevel1();
	afx_msg void OnOptionLevel2();
	afx_msg void OnOptionLevel3();
	afx_msg void OnOptionLevel4();
	afx_msg void OnOptionLevel5();
	afx_msg void OnOptionLevel6();
	afx_msg void OnUpdateOptionGrid(CCmdUI* pCmdUI);
	afx_msg void OnOptionGrid();
	afx_msg void OnUpdateOptionMusic(CCmdUI* pCmdUI);
	afx_msg void OnOptionMusic();
	afx_msg void OnUpdateGamePaush(CCmdUI* pCmdUI);
	afx_msg void OnGamePaush();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in HWRECTView.cpp
inline CHWRECTDoc* CHWRECTView::GetDocument()
   { return (CHWRECTDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_HWRECTVIEW_H__8B080E4F_DF7E_11D2_A2DF_00A0248D3AC7__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -