VC++俄罗斯方块课程设计报告含源代码Word格式.docx
- 文档编号:5362189
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:100
- 大小:242.97KB
VC++俄罗斯方块课程设计报告含源代码Word格式.docx
《VC++俄罗斯方块课程设计报告含源代码Word格式.docx》由会员分享,可在线阅读,更多相关《VC++俄罗斯方块课程设计报告含源代码Word格式.docx(100页珍藏版)》请在冰点文库上搜索。
1、程序的整个流程图
N
Y
2、键盘响应函数流程图
NNY
YN
\NY
NY
Y
N
3、等级管理模块流程图
4、主界面显示模块流程图
N
(1)类1:
CAboutDlg()类是建立MFC程序时自动生成的类,俄罗斯方块游戏基本上用不到这个类,故不做解释。
(2)类2:
CMainFrame()框架类主要是对游戏的框架进行设计。
数据成员:
CStatusBarm_wndStatusBar;
工具栏
CToolBarm_wndToolBar;
状态栏
成员函数:
1、CMainFrame()构造函数:
初始化游戏;
2、~CMainFrame()析构函数:
删除游戏数据;
3、OnCreate():
工具栏的实现;
4、PreCreateWindow()游戏窗口的规格实现;
(3)类3:
COptionDlg()游戏状态显示类:
主要实现对游戏在进行中的一些状态显示比如:
级别、下一个方块。
intm_oldArea;
区域大小
intm_oldLevel;
等级
intm_oldBlockSytle;
背景风格
BOOLm_oldDrawGrid;
1、COptionDlg()初始化界面:
用户选择的区域大小代码,及级别代码,方块样式
2、DoDataExchange()数据类型的转换:
由键盘消息转换成函数响应消息
3、Onok()当用户按OK按钮(ID是IDOK)时调用。
覆盖该函数执行OK按钮动作。
对话框包括自动数据检验和交换,缺省方式是对应用的某些变量进行数据的检验和更新。
(4)CSkyblue_RectApp()程序自动生成。
(5)CSkyblue_RectView()视图类:
这是本游戏主要编写的地方:
实现方块的随机生成、方块的移动、变形。
游戏的消行、升级、速度的提升以及游戏的开始和结束。
intm_nWidth;
子窗口的宽度
intm_nHeight;
子窗口的高度
intm_iCol;
intm_iRow;
列与行的数量
intm_iLarge;
(小方块的大小,它会随着行与列的不同而不同,具体为:
12行10列,30个象素的正方形
18行15列,20
24行20列,15
30行25列,12)
intm_iLevel;
当前的级别,换算成速度的算法为:
1500-m_iLevel*200
intm_iBlockSytle;
当前选择的方块显示样式
intm_iStartX;
intm_iStartY;
游戏区域左上角的坐标
BOOLIsLeftLimit();
坠物件是否可向左移动
BOOLIsRightLitmit();
intInterFace[74][4];
接触面二维数组,记录1~7种下坠物的1~4种形态的接触面信息,把该下坠物的某种形态种的4个方块,有接触面则记录方位,无则为-1标识。
intm_currentRect;
当前的方块形状
CStringm_strArea;
CStringm_strLevel;
当前的样式,下一个将会出现的样式
intm_icurrentStatus;
intm_inextStatus;
OnDraw中需要用到的设备名称
CPen*m_pBlackPen;
CBrush*m_pGrayBrush;
CBrush*m_pBlackBrush;
BOOLm_bDrawGrid;
是否画网格线
intm_iPerformance;
游戏总成绩
BOOLm_bGameEnd;
游戏是否已结束,为FALSE表示开始,否则为结束
成员函数1、ActiveStatusToGameStatus()将当前下坠物的位置映射到游戏区域地图数组中去;
2、CSkyblue_RectView()初始化游戏;
3、~CSkyblue_RectView()删除游戏数据;
4、CurrentAreaAndLevel()用于生成当前区域大小与级别所对应的汉字描述;
5、DCEnvClear()调取位图资源;
6、DcEnvInitial()绘图环境初始化;
7、DrawGame(CDC*pDC)绘制整个游戏所在窗口的背景;
8、InvalidateCurrent()刷新当前的区域;
9、IsBottom()判断当前方块是否已到底,并且销行等相关的工作;
10、IsLeftLimit()方块是否还可以左移;
11、IsRightLitmit()方块是否还可以右移;
12、OnCreate(LPCREATESTRUCTlpCreateStruct)创建一些设备;
13、OnDraw(CDC*pDC)承担所有绘制屏幕工作;
14、OnGameEnd()游戏结束;
15、OnGameExit()清理内存设备环境,释放资源;
16、OnGameOption()游戏设置;
17、OnGamePaush()游戏暂停;
18、OnGameStart()游戏开始;
19、OnKeyDown(UINTnChar,UINTnRepCnt,UINTnFlags)()处理用户的输入,方块的左,右移,加速及变形;
20、OnOptionArea()用菜单设置区域大小;
21、OnOptionLevel1()用菜单设置游戏级别:
22、OnTimer()承担所有驱动工作;
23、OnUpdateGameEnd(CCmdUI*pCmdUI)()如果游戏开始,则此[游戏结束]按钮被开启;
24、OnUpdateGameExit(CCmdUI*pCmdUI)如果游戏开始,则此[退出系统]按钮被屏蔽;
25、OnUpdateGamePaush(CCmdUI*pCmdUI)如游戏开始,则[游戏暂停]按钮开启
26、Random(intMaxNumber):
产生一个最大值不大于指定值的随机正整数(Random);
27、RectArrow(intm_Type):
当前方块下降加速,左移,右移
28、RectChange():
方块的变形
29、RectDown()当前方块下降
30、RectStatusToActiveStatus(intm_which)初始掉落时,将根据方块的样式决定当前动态数组的值
31、RectStatusToNextStatus(intm_which)初始掉落时,将根据方块的样式决定下一次将要掉下来的动态数组的值
32、
3.类之间的关系:
四.编写代码
1.问题1
(1)问题描述:
所遇问题的描述。
(2)解决办法:
该问题的解决办法。
2.问题2
……………………………………………
五.程序运行
1、游戏主页面
:
游戏主界面,上方是开始、暂停、结束、设置按钮。
设置按钮
2、游戏开始:
注:
右上角是下一个方块
右下角分别显示分数、游戏大小和级别。
3、开始时可以按暂停按钮出现下面情况
开始按钮被激活
4、按结束按钮出现
设置按钮激活
5、消行及得分
6、升级
7、游戏结束
3.错误描述及其解决办法
(1)问题1:
问题描述:
解决办法:
(2)问题2
问题描述:
该问题的解决办法
………………………………………
六、感想认识
通过本次课程设计,谈谈对面向对象编程的体会。
七.程序代码
skyblue_Rect.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"
stdafx.h"
skyblue_Rect.h"
MainFrm.h"
skyblue_RectDoc.h"
skyblue_RectView.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CSkyblue_RectApp
BEGIN_MESSAGE_MAP(CSkyblue_RectApp,CWinApp)
//{{AFX_MSG_MAP(CSkyblue_RectApp)
ON_COMMAND(ID_APP_ABOUT,OnAppAbout)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG_MAP
//Standardfilebaseddocumentcommands
ON_COMMAND(ID_FILE_NEW,CWinApp:
:
OnFileNew)
ON_COMMAND(ID_FILE_OPEN,CWinApp:
OnFileOpen)
//Standardprintsetupcommand
ON_COMMAND(ID_FILE_PRINT_SETUP,CWinApp:
OnFilePrintSetup)
END_MESSAGE_MAP()
//CSkyblue_RectAppconstruction
CSkyblue_RectApp:
CSkyblue_RectApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
}
//TheoneandonlyCSkyblue_RectAppobject
CSkyblue_RectApptheApp;
//CSkyblue_RectAppinitialization
BOOLCSkyblue_RectApp:
InitInstance()
AfxEnableControlContainer();
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();
//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();
//CallthiswhenlinkingtoMFCstatically
//Changetheregistrykeyunderwhichoursettingsarestored.
Youshouldmodifythisstringtobesomethingappropriate
//suchasthenameofyourcompanyororganization.
SetRegistryKey(_T("
LocalAppWizard-GeneratedApplications"
));
LoadStdProfileSettings(0);
//LoadstandardINIfileoptions(includingMRU)
//Registertheapplication'
sdocumenttemplates.Documenttemplates
//serveastheconnectionbetweendocuments,framewindowsandviews.
CSingleDocTemplate*pDocTemplate;
pDocTemplate=newCSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSkyblue_RectDoc),
RUNTIME_CLASS(CMainFrame),//mainSDIframewindow
RUNTIME_CLASS(CSkyblue_RectView));
AddDocTemplate(pDocTemplate);
//Parsecommandlineforstandardshellcommands,DDE,fileopen
CCommandLineInfocmdInfo;
ParseCommandLine(cmdInfo);
//Dispatchcommandsspecifiedonthecommandline
if(!
ProcessShellCommand(cmdInfo))
returnFALSE;
//Theoneandonlywindowhasbeeninitialized,soshowandupdateit.
m_pMainWnd->
ShowWindow(SW_SHOW);
UpdateWindow();
returnTRUE;
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);
//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
CAboutDlg():
CDialog(CAboutDlg:
IDD)
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
voidCAboutDlg:
DoDataExchange(CDataExchange*pDX)
CDialog:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Appcommandtorunthedialog
voidCSkyblue_RectApp:
OnAppAbout()
CAboutDlgaboutDlg;
aboutDlg.DoModal();
//CSkyblue_RectAppmessagehandlers
//OptionDlg.cpp:
implementationfile
OptionDlg.h"
//COptionDlgdialog
COptionDlg:
COptionDlg(intm_iArea,intm_iLevel,intm_iBlockStyle,BOOLm_bMusic,BOOLm_bDrawGrid,CWnd*pParent/*=NULL*/)
:
CDialog(COptionDlg:
IDD,pParent)
m_oldArea=m_iArea;
m_oldLevel=m_iLevel;
m_oldBlockSytle=m_iBlockStyle;
m_oldMusic=m_bMusic;
m_oldDrawGrid=m_bDrawGrid;
//{{AFX_DATA_INIT(COptionDlg)
m_bMusic=FALSE;
m_bDrawGrid=FALSE;
voidCOptionDlg:
//{{AFX_DATA_MAP(COptionDlg)
DDX_Check(pDX,IDC_CHECK_GRID,m_bDrawGrid);
DDX_Check(pDX,IDC_CHECK_MUSIC,m_bMusic);
BEGIN_MESSAGE_MAP(COptionDlg,CDialog)
//{{AFX_MSG_MAP(COptionDlg)
ON_WM_CREATE()
//NOTE:
theClassWizardwilladdmessagemapmacroshere
//COptionDlgmessagehandlers
intCOptionDlg:
OnCreate(LPCREATESTRUCTlpCreateStruct)
if(CDialog:
OnCreate(lpCreateStruct)==-1)
return-1;
return0;
BOOLCOptionDlg:
OnInitDialog()
OnInitDialog();
//参传来的参数赋初值
CComboBox*m_comboArea;
CComboBox*m_comboLevel;
CComboBox*m_comboBlockStyle;
CButton*m_btnDrawGrid;
CButton*m_btnMusic;
m_comboArea=(CComboBox*)GetDlgItem(IDC_COMBO_AREA);
m_comboArea->
SetCurSel(m_oldArea);
m_comboLevel=(
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VC 俄罗斯方块 课程设计 报告 源代码
![提示](https://static.bingdoc.com/images/bang_tan.gif)