现在的位置: 首页 > 综合 > 正文

vc项目开发:俄罗斯方块制作日志

2019年04月27日 ⁄ 综合 ⁄ 共 48985字 ⁄ 字号 评论关闭

vc项目日志,俄罗斯方块开发


                   ----July


 

mfc初学一个月时,所写的俄罗斯方块。共享下源码。

July、2010/10/21

-------------------------------------------------------------

 

此为View.h文件

  1. /*-------------------------------------
     
  2. View.h文件
     
  3. July/2010、10月
     
  4. --------------------------------------*/
      
  5.   
  6. // skyjuly_RecTTView.h : interface of the CSkyjuly_RecTTView class
      
  7. //
      
  8. /////////////////////////////////////////////////////////////////////////////
      
  9.   
  10. #if !defined(AFX_SKYJULY_RECTTVIEW_H__BBD13113_594E_4BE6_9DA5_1DAE3EC53ED8__INCLUDED_)
      
  11. #define AFX_SKYJULY_RECTTVIEW_H__BBD13113_594E_4BE6_9DA5_1DAE3EC53ED8__INCLUDED_
      
  12.   
  13. #if _MSC_VER > 1000
      
  14. #pragma once
      
  15. #endif // _MSC_VER > 1000
      
  16.   
  17.   
  18.   
  19. // 宏变量:白色和黑色
      
  20. #define WHITE RGB(255,255,255)
      
  21. #define BLACK RGB(0,0,0)
      
  22. #define BLUE RGB(0,0,255)
      
  23.   
  24. //中断操作的运动趋势
      
  25. #define LEFT  0      //向左移动
      
  26. #define RIGHT 1      //向左移动
      
  27. #define UP    2     //向上(变形)      
      
  28. #define DOWN  3      //向下移动(加速)
      
  29.   
  30. //游戏区域地图最大限制
      
  31. #define  MAX_ROW    100     //地图的最大行数
      
  32. #define  MAX_COL    100      //地图的最大列数
      
  33.   
  34. //地图状态
      
  35. #define MAP_STATE_EMPTY             0    //空(未被占据)
      
  36. #define MAP_STATE_NOT_EMPTY         1    //被占据
      
  37.   
  38. class
     CSkyjuly_RecTTView : 
    public
     CView  
  39. {  
  40. protected

    // create from serialization only
      
  41.     CSkyjuly_RecTTView();  
  42.     DECLARE_DYNCREATE(CSkyjuly_RecTTView)  
  43.   
  44. // Attributes
      
  45. public
    :  
  46.     CSkyjuly_RecTTDoc* GetDocument();  
  47.   
  48. // Operations
      
  49. public
    :  
  50.   
  51. // Overrides
      
  52.     // ClassWizard generated virtual function overrides
      
  53.     //{{AFX_VIRTUAL(CSkyblue_RectView)
      
  54.     public
    :  
  55.     virtual
     
    void
     OnDraw(CDC* pDC);  
    // overridden to draw this view
      
  56.     virtual
     
    BOOL
     PreCreateWindow(CREATESTRUCT& cs);  
  57.     //}}AFX_VIRTUAL
      
  58.   
  59. // Implementation
      
  60. public
    :  
  61.     virtual
     ~CSkyjuly_RecTTView();  
  62.   
  63. protected
    :  
  64.     int
     m_nWidth;  
    //子窗口的宽度
      
  65.     int
     m_nHeight; 
    //子窗口的高度
      
  66.   
  67.     //列与行的数量
      
  68.     int
     m_iCol;  
  69.     int
     m_iRow;  
  70.   
  71.     //小方块的大小,它会随着行与列的不同而不同,具体为:
      
  72.     // 12行10列,30个象素的正方形
      
  73.     // 18行15列,20
      
  74.     // 24行20列,15
      
  75.     // 30行25列,12
      
  76.     int
     m_iLarge;  
  77.   
  78.     //当前的级别,换算成速度的算法为:1500 - m_iLevel*200
      
  79.     int
     m_iLevel;  
  80.     //当前选择的方块显示样式
      
  81.     int
     m_iBlockSytle;  
  82.   
  83.     //游戏区域左上角的坐标
      
  84.     int
     m_iStartX;  
  85.     int
     m_iStartY;  
  86.   
  87.     BOOL
     IsLeftLimit();       
    //下坠物件是否可向左移动
      
  88.     BOOL
     IsRightLimit();  
  89.   
  90.     //接触面二维数组,记录1~7种下坠物的1~4种形态的接触面信息
      
  91.     //我们把该下坠物的某种形态种的4个方块,有接触面则记录方位,无则为-1标识。
      
  92.     int
     InterFace[74][4];  
  93.       
  94.     //当前的方块形状
      
  95.     int
     m_currentRect;  
  96.   
  97.     //判断当前方块是否到底
      
  98.   
  99. void
     IsBottom();  
  100.     //当前方块下降
      
  101.     void
     RectDown();  
  102.   
  103.     //当前方块加速:UP,左移:LEFT,右移:RIGHT
      
  104.     void
     RectArrow(
    int
     m_Type);  
  105.       
  106. //根据下坠物的类型映射出它的具体形态  功能组
      
  107. //根据旧的下一下坠物映射出当前激活状态下的下坠物形态
      
  108.     void
     RectStatusToActiveStatus(
    int
     m_which);   
  109. //根据下坠物形态映射出下一下坠物的形态
      
  110.     void
     RectStatusToNextStatus(
    int
     m_which);   
  111. //将当前的状态映射到地图游戏区域
      
  112.     void
     ActiveStatusToGameStatus();   
  113.   
  114.   
  115.     int
     Random(
    int
     MaxNumber);  
  116.     //标识方块已到底的变量,到底为TRUE
      
  117.     BOOL
     m_isBottom;  
  118.   
  119.     //用于标志方块状态的数组,大小由横格与竖格数据决定,为1表示该方块显示,或者不显示
      
  120.     //画形状只需要修改数组中相应元素的状态值即可
      
  121.     //由时钟控制,定时在OnPaint函数中根据数组画方块
      
  122.     int
     GameStatus[MAX_ROW][MAX_COL];  
  123.   
  124.     //用于保存当前方块的动态位置,4个小方块分别在大数组中的位置
      
  125.     //存放位置为先左后右,每一列又遵循先上后下的原则
      
  126.     int
     ActiveStatus[4][2];  
  127.   
  128.     //存入下一次要出来的方块的模样的数组
      
  129.     int
     NextStatus[4][2];  
  130.   
  131. // Generated message map functions
      
  132. protected
    :  
  133.     BOOL
     m_bGamePaush;  
  134.     void
     StopMid();  
  135.     void
     PlayMid();  
  136.     void
     CurrentAreaAndLevel();  
  137.     //用于记录当前区域大小与当前级别的字符串,用于显示在屏幕上提示用户当前状态
      
  138.     CString m_strArea;  
  139.     CString m_strLevel;  
  140.   
  141.     //当前的样式 ,下一个将会出现的样式
      
  142.     int
     m_icurrentStatus;  
  143.     int
     m_inextStatus;  
  144.   
  145.     //OnDraw中需要用到的设备名称
      
  146.     CPen *m_pBlackPen;  
  147.     CBrush *m_pGrayBrush;  
  148.     CBrush *m_pBlackBrush;  
  149.   
  150.     //是否画网格线
      
  151.     BOOL
     m_bDrawGrid;  
  152.   
  153.     //是否插放背景音乐
      
  154.     BOOL
     m_bMusic;  
  155.   
  156.     //游戏总成绩
      
  157.     int
     m_iPerformance;  
  158.   
  159.     //游戏是否已结束,为FALSE表示开始,否则为结束
      
  160.     BOOL
     m_bGameEnd;  
  161.       
  162.     //刷新指定的区域,它的大小为:四个小方块所在的正方形的大小
      
  163.     void
     InvalidateCurrent();  
  164.   
  165.     //内存绘图设备的处理
      
  166.     CDC m_memDC;                   //内存设备环境 
      
  167.     CBitmap m_memBmp;              //内存位图
      
  168.   
  169.     CDC m_memRectDC;       //方块内存设备环境
      
  170.     HBITMAP
     m_hMemRectBmp;  
    //方块内存位图句柄
      
  171.   
  172.     int
     m_bFistPlay;               
    //是否是第一次开始游戏
      
  173.     void
     DcEnvInitial(
    void
    );   
  174.     void
     DCEnvClear(
    void
    );  
  175.     void
     DrawGame(CDC *pDC);  
  176.   
  177.   
  178. // Generated message map functions
      
  179. protected
    :  
  180.     void
     RectChange();  
  181.     //{{AFX_MSG(CSkyjuly_RecTTView)
      
  182.     afx_msg void
     OnGameStart();  
  183.     afx_msg void
     OnGamePaush();  
  184.     afx_msg void
     OnGameEnd();  
  185.     afx_msg void
     OnGameExit();  
  186.     afx_msg void
     OnGameOption();  
  187.     afx_msg int
     OnCreate(LPCREATESTRUCT lpCreateStruct);  
  188.     afx_msg void
     OnTimer(
    UINT
     nIDEvent);  
  189.     afx_msg void
     OnKeyDown(
    UINT
     nChar, 
    UINT
     nRepCnt, 
    UINT
     nFlags);  
  190.     //}}AFX_MSG
      
  191.     DECLARE_MESSAGE_MAP()  
  192. };  
  193.   
  194. #ifndef _DEBUG  // debug version in skyjuly_RecTTView.cpp
      
  195. inline
     CSkyjuly_RecTTDoc* CSkyjuly_RecTTView::GetDocument()  
  196.    { return
     (CSkyjuly_RecTTDoc*)m_pDocument; }  
  197. #endif
      
  198.   
  199. /////////////////////////////////////////////////////////////////////////////
      
  200.   
  201. //{{AFX_INSERT_LOCATION}}
      
  202. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
      
  203.   
  204. #endif // !defined(AFX_SKYJULY_RECTTVIEW_H__BBD13113_594E_4BE6_9DA5_1DAE3EC53ED8__INCLUDED_)
      

 

以下为View.cpp文件。

  1. /*--------------------------------------
     
  2. View.cpp文件。
     
  3. July、2010/10月
     
  4. --------------------------------------*/
      
  5.   
  6. // skyjuly_RecTTView.cpp : implementation of the CSkyjuly_RecTTView class
      
  7. //
      
  8.   
  9. #include "stdafx.h"
      
  10. #include "skyjuly_RecTT.h"
      
  11.   
  12. #include "skyjuly_RecTTDoc.h"
      
  13. #include "skyjuly_RecTTView.h"
      
  14. #include "OptionDlg.h"
      
  15.   
  16. #ifdef _DEBUG
      
  17. #define new DEBUG_NEW
      
  18. #undef THIS_FILE
      
  19. static
     
    char
     THIS_FILE[] = __FILE__;  
  20. #endif
      
  21.   
  22. /////////////////////////////////////////////////////////////////////////////
      
  23. // CSkyjuly_RecTTView
      
  24.   
  25. IMPLEMENT_DYNCREATE(CSkyjuly_RecTTView, CView)  
  26.   
  27. BEGIN_MESSAGE_MAP(CSkyjuly_RecTTView, CView)  
  28.     //{{AFX_MSG_MAP(CSkyjuly_RecTTView)
      
  29.     ON_COMMAND(ID_GAME_START, OnGameStart)  
  30.     ON_COMMAND(ID_GAME_PAUSH, OnGamePaush)  
  31.     ON_COMMAND(ID_GAME_END, OnGameEnd)  
  32.     ON_COMMAND(ID_GAME_EXIT, OnGameExit)  
  33.     ON_COMMAND(ID_GAME_OPTION, OnGameOption)  
  34.     ON_WM_CREATE()  
  35.     ON_WM_TIMER()  
  36.     ON_WM_KEYDOWN()  
  37.     //}}AFX_MSG_MAP
      
  38.     // Standard printing commands
      
  39.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)  
  40.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)  
  41.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)  
  42. END_MESSAGE_MAP()  
  43.   
  44. /////////////////////////////////////////////////////////////////////////////
      
  45. // CSkyjuly_RecTTView construction/destruction
      
  46.   
  47. CSkyjuly_RecTTView::CSkyjuly_RecTTView()  
  48. {  
  49.     // TODO: add construction code here
      
  50.     //第一次开始游戏
      
  51.     m_bFistPlay = TRUE;  
  52.   
  53.     //缺省为不是游戏暂停状态
      
  54.     m_bGamePaush = FALSE;  
  55.   
  56.     //缺省为不插放背景音乐
      
  57.     m_bMusic = FALSE;  
  58.       
  59.     //缺省为画网格线
      
  60.     m_bDrawGrid = TRUE;  
  61.   
  62.     //总分值清零
      
  63.     m_iPerformance = 0;  
  64.   
  65.     //测试值:为12行,10列
      
  66.     m_iRow = 12;  
  67.     m_iCol = 10;  
  68.   
  69.     //左上角X,Y坐标
      
  70.     m_iStartX = 10;  
  71.     m_iStartY = 10;  
  72.   
  73.     //缺省级别为3级
      
  74.     m_iLevel = 2;  
  75.     //第一种样式
      
  76.     m_iBlockSytle = 0;  
  77.   
  78.     //缺省方块大小为m_iLarge个象素
      
  79.     m_iLarge = 30;  
  80.   
  81.     //缺省游戏是结束的
      
  82.     m_bGameEnd = TRUE;  
  83.   
  84.     int
     i,j;  
  85.   
  86.     //赋初值
      
  87.     for
     (i=0;i<100;i++)  
  88.         for
     (j=0;j<100;j++)  
  89.             GameStatus[i][j]=0;  
  90.   
  91.     //各种形状方块的接触面数据,参见设计书的接触面表格, 
      
  92.     //如果某种形状的方块没有4个接触面,则后面的数据填-1
      
  93.     for
     (i=0;i<74;i++)  
  94.         for
     (j=0;j<4;j++)  
  95.             InterFace[i][j] = -1;  
  96. /*
     
  97. 1  ----
     
  98. */
      
  99.     InterFace[1][0] = 3;  
  100.       
  101.     InterFace[11][0] = 0;   InterFace[11][1] = 1;   InterFace[11][2] = 2;   InterFace[11][3] = 3;  
  102. /*
     
  103. 2   --
     
  104.     --
     
  105. */
        
  106.     InterFace[2][0] = 1;    InterFace[2][1] = 3;  
  107. /*
     
  108. 3   -
     
  109.    ---
     
  110.  
  111. */
        
  112.     InterFace[3][0] = 0;    InterFace[3][1] = 2;    InterFace[3][2] = 3;  
  113.       
  114.     InterFace[31][0] = 2;   InterFace[31][1] = 3;  
  115.       
  116.     InterFace[32][0] = 0;   InterFace[32][1] = 2;   InterFace[32][2] = 3;  
  117.       
  118.     InterFace[33][0] = 0;   InterFace[33][1] = 3;  
  119. /*  
  120. 4  --  
  121.   --  
  122. */    
  123.     InterFace[4][0] = 1;    InterFace[4][1] = 3;  
  124.       
  125.     InterFace[41][0] = 0;   InterFace[41][1] = 2;   InterFace[41][2] = 3;  
  126. /*
     
  127. 5  --
     
  128.     --
     
  129. */
        
  130.     InterFace[5][0] = 1;    InterFace[5][1] = 3;  
  131.   
  132.     InterFace[51][0] = 0;   InterFace[51][1] = 2;   InterFace[51][2] = 3;  
  133. /*
     
  134. 6  --
     
  135.     -
     
  136.     -
     
  137. */
        
  138.     InterFace[6][0] = 0;    InterFace[6][1] = 3;  
  139.       
  140.     InterFace[61][0] = 1;   InterFace[61][1] = 2;   InterFace[61][2] = 3;  
  141.   
  142.     InterFace[62][0] = 2;   InterFace[62][1] = 3;  
  143.   
  144.     InterFace[63][0] = 0;   InterFace[63][1] = 1;   InterFace[63][2] = 3;  
  145. /*
     
  146. 7  --
     
  147.    -
     
  148.    -
     
  149. */
      
  150.     InterFace[7][0] = 2;    InterFace[7][1] = 3;      
  151.     InterFace[71][0] = 1;   InterFace[71][1] = 2;   InterFace[71][2] = 3;  
  152.   
  153.     InterFace[72][0] = 0;   InterFace[72][1] = 3;  
  154.   
  155.     InterFace[73][0] = 0;   InterFace[73][1] = 1;   InterFace[73][2] = 3;  
  156.   
  157.   
  158.   
  159. }  
  160.   
  161. CSkyjuly_RecTTView::~CSkyjuly_RecTTView()  
  162. {  
  163. }  
  164.   
  165.   
  166.   
  167. BOOL
     CSkyjuly_RecTTView::PreCreateWindow(CREATESTRUCT& cs)  
  168. {  
  169.     // TODO: Modify the Window class or styles here by modifying
      
  170.     //  the CREATESTRUCT cs
      
  171.   
  172.     return
     CView::PreCreateWindow(cs);  
  173. }  
  174.   
  175. /////////////////////////////////////////////////////////////////////////////
      
  176. // CSkyjuly_RecTTView drawing
      
  177.   
  178. void
     CSkyjuly_RecTTView::OnDraw(CDC* pDC)  
  179. {  
  180.     /*CSkyjuly_RecTTDoc* pDoc = GetDocument();
     
  181.     ASSERT_VALID(pDoc);*/
      
  182.     // TODO: add draw code for native data here
      
  183.     DcEnvInitial();  
  184.     DrawGame(&m_memDC);  //在内存位图的游戏区域绘制
      
  185.   
  186.     pDC->BitBlt(0,0,m_nWidth,m_nHeight,&m_memDC,0,0,SRCCOPY);  
  187. }  
  188.   
  189.   
  190.   
  191. /////////////////////////////////////////////////////////////////////////////
      
  192. // CSkyjuly_RecTTView diagnostics
      
  193.   
  194. #ifdef _DEBUG
      
  195. #endif //_DEBUG
      
  196.   
  197. /////////////////////////////////////////////////////////////////////////////
      
  198. // CSkyjuly_RecTTView message handlers
      
  199.   
  200. void
     CSkyjuly_RecTTView::OnGameStart()   
  201. {  
  202.     // TODO: Add your command handler code here
      
  203.     if
     (!m_bGamePaush)  
    //如果不是游戏暂停状态,则必须作些初始工作
      
  204.     {  
  205.         m_bGameEnd = FALSE;  
  206.         //总分值清零, 并显示总分记分牌
      
  207.         m_iPerformance = 0;  
  208.       
  209.         //显示当前的区域及游戏级别的汉字描述
      
  210.     //  CurrentAreaAndLevel();
      
  211.           
  212.         CRect rect(m_iStartY, m_iStartX, m_iStartY+440, m_iStartX+370);  
  213.         InvalidateRect(&rect);  
  214.     }  
  215.   
  216.     m_bGamePaush = FALSE;  
  217.     SetTimer(1,1500-250*m_iLevel,NULL);  
  218.   
  219. }  
  220.   
  221.   
  222.   
  223. void
     CSkyjuly_RecTTView::OnGamePaush()   
  224. {  
  225.     // TODO: Add your command handler code here
      
  226.     m_bGamePaush = TRUE;  
  227.   
  228.     KillTimer(1);  
  229.       
  230. }  
  231.   
  232. void
     CSkyjuly_RecTTView::OnGameEnd()   
  233. {  
  234.     // TODO: Add your command handler code here
      
  235.     m_bGameEnd = TRUE;  
  236.   
  237.     int
     i,j;  
  238.     for
     (i=0;i<m_iRow;i++)  
  239.         for
     (j=0;j<m_iCol;j++)  
  240.             GameStatus[i][j]=0;  
  241.   
  242.     CRect rect(m_iStartY, m_iStartX, m_iStartY+440, m_iStartX+370);  
  243.     InvalidateRect(&rect);  
  244.   
  245.     m_bGamePaush = FALSE;  //清除游戏暂停状态
      
  246.   
  247.     KillTimer(1);     
  248. }  
  249.   
  250. void
     CSkyjuly_RecTTView::OnGameExit()   
  251. {  
  252.     // TODO: Add your command handler code here
      
  253.       
  254. }  
  255.   
  256.   
  257. void
     CSkyjuly_RecTTView::OnGameOption()   
  258. {  
  259.     // TODO: Add your command handler code here
      
  260.     //参数顺序: 区域大小代码:0-3,分别为:12X10,18X15,24X20,m_iLargeX25
      
  261.     //级别:0-5,分别为:1500,1200,1000,800,600,400
      
  262.     //背景音乐:TRUE 或者 FALSE
      
  263.     int
     m_lsArea;  
  264. /*  switch(m_iRow)
     
  265.     {
     
  266.     case 12:
     
  267.         m_lsArea = 0;
     
  268.         break;
     
  269.     case 18:
     
  270.         m_lsArea = 1;
     
  271.         break;
     
  272.     case 24:
     
  273.         m_lsArea = 2;
     
  274.         break;
     
  275.     case 30:
     
  276.         m_lsArea = 3;
     
  277.         break;
     
  278.     }*/
      
  279.   
  280.     COptionDlg dlg(m_lsArea,m_iLevel,m_iBlockSytle,m_bMusic,m_bDrawGrid);  
  281.       
  282.     if
     (dlg.DoModal()==IDOK)  
  283.     {  
  284.         //确定区域的大小
      
  285.     /*  switch(dlg.m_iArea)
     
  286.         {
     
  287.         case 0:
     
  288.             m_iRow = 12;
     
  289.             m_iCol = 10;
     
  290.             m_iLarge = 30;
     
  291.             break;
     
  292.         case 1:
     
  293.             m_iRow = 18;
     
  294.             m_iCol = 15;
     
  295.             m_iLarge = 20;
     
  296.             break;
     
  297.         case 2:
     
  298.             m_iRow = 24;
     
  299.             m_iCol = 20;
     
  300.             m_iLarge = 15;
     
  301.             break;
     
  302.         case 3:
     
  303.             m_iRow = 30;
     
  304.             m_iCol = 25;
     
  305.             m_iLarge = 12;
     
  306.             break;
     
  307.         }
     
  308.  
  309.         //确定级别
     
  310.         m_iLevel = dlg.m_iLevel;
     
  311.         //选择的样式
     
  312.         m_iBlockSytle = dlg.m_iBlockStyle;
     
  313.  
  314.         //确定是否绘网格背景
     
  315.         m_bDrawGrid = dlg.m_bDrawGrid;
     
  316.  
  317.         //检查是否插放音乐                                
     
  318.         m_bMusic = dlg.m_bMusic;
     
  319.     //  if (m_bMusic)
     
  320. //          PlayMid();
     
  321.     //  else
     
  322.     //      StopMid();
     
  323.  
  324.         Invalidate();*/
      
  325.     }     
  326.       
  327. }  
  328.   
  329.   
  330. void
     CSkyjuly_RecTTView::DrawGame(CDC *pDC)  
  331. {  
  332.     int
     i,j;  
  333.     //选用黑色画刷,绘制整个游戏所在窗口的背景
      
  334.     pDC -> SelectObject(m_pBlackBrush);  
  335.     CRect rect;  
  336.     GetClientRect(&rect);  
  337.     pDC -> Rectangle(rect);  
  338.   
  339.     //选用灰色画刷,绘制游戏区域的背景
      
  340.     pDC -> SelectObject(m_pGrayBrush);  
  341.     pDC -> Rectangle(m_iStartY ,m_iStartX, m_iStartY + 301, m_iStartX + 360);      
  342.   
  343.     pDC->SelectObject(m_pBlackPen);    
  344.     //画网格线
      
  345.     if
     (m_bDrawGrid)  
  346.     {  
  347.         //画横线
      
  348.         for
     (i=0;i<m_iRow;i++)  
  349.         {  
  350.             pDC->MoveTo(m_iStartY, m_iStartX + i*m_iLarge);  
  351.             pDC->LineTo(m_iStartY+300, m_iStartX +i*m_iLarge);  
  352.         }     
  353.           
  354.         //画竖线
      
  355.         for
     (i=0;i<m_iCol;i++)  
  356.         {  
  357.             pDC->MoveTo(m_iStartY+i*m_iLarge, m_iStartX);  
  358.             pDC->LineTo(m_iStartY+i*m_iLarge, m_iStartX+360);  
  359.         }  
  360.     }  
  361.   
  362.     int
     x,y,nW,nH;  
  363.   
  364.     //小方块的绘制
      
  365.     for
     (i=0;i<m_iRow;i++)  
  366.         for
     (j=0;j<m_iCol;j++)  
  367.         {  
  368.             if
     (GameStatus[i][j]==MAP_STATE_NOT_EMPTY)  
  369.             {  
  370.                 //在游戏区域中状态为被占用状态的区域绘制小方块
      
  371.                 x = m_iStartY+j*m_iLarge +2;  
  372.                 y = m_iStartX+i*m_iLarge +2;  
  373.                 nW = m_iLarge-4;  
  374.                 nH = m_iLarge-4;  
  375.             pDC->BitBlt(x,y,nW,nH,&m_memRectDC,m_iBlockSytle*30,0,SRCCOPY);  
  376.             }  
  377.         }  
  378.   
  379.     //显示游戏区域及游戏级别的汉字描述
      
  380.     if
     (!m_bGameEnd)  
  381.     {  
  382.         pDC -> SetBkColor(BLACK);  
  383.         pDC -> SetTextColor(WHITE);  
  384.         pDC -> TextOut(m_iStartY+320, m_iStartX+220, "游戏区域大小:"
    );  
  385.         pDC -> TextOut(m_iStartY+320, m_iStartX+240,m_strArea);  
  386.   
  387.         pDC -> TextOut(m_iStartY+320, m_iStartX+280, "游戏级别:"
    );  
  388.         pDC -> TextOut(m_iStartY+320, m_iStartX+300,m_strLevel);  
  389.     }  
  390.                   
  391.     //显示总分
      
  392.     if
     (!m_bGameEnd)  
  393.     {  
  394.         CString lsStr;    
  395.         lsStr.Format("总分为:%d 分"
    ,m_iPerformance);  
  396.         pDC -> SetBkColor(BLACK);  
  397.         pDC -> SetTextColor(WHITE);  
  398.         pDC -> TextOut(m_iStartY+320, m_iStartX+180,lsStr);  
  399.     }  
  400.   
  401.     //画下一次将要出现的方块,用于提示用户
      
  402.     if
     (!m_bGameEnd)  
  403.     {  
  404.         pDC -> SetBkColor(BLACK);  
  405.         pDC -> SetTextColor(WHITE);  
  406.         pDC -> TextOut(m_iStartY+320, m_iStartX,"下一个方块:"
    );  
  407.   
  408.         int
     x,y,nW,nH;        
  409.         for
     (
    UINT
     k=0;k<4;k++)  
  410.         {  
  411.             i = NextStatus[k][0];  
  412.             j = NextStatus[k][1];  
  413.   
  414.                 x = m_iStartY+j*30 +2+320;  
  415.                 y = m_iStartX+i*30 +2+30;  
  416.                 nW = m_iLarge-4;  
  417.                 nH = m_iLarge-4;  
  418.         pDC->BitBlt(x,y,nW,nH,&m_memRectDC,m_iBlockSytle*30,0,SRCCOPY);  
  419.         }  
  420.     }  
  421.   
  422. }  
  423.   
  424.   
  425.   
  426. void
     CSkyjuly_RecTTView::DcEnvInitial()  
  427. {  
  428.     if
    (m_bFistPlay)  
  429.     {  
  430.         m_bFistPlay = FALSE;  
  431.         //用默认的参数,获取当前屏幕设备环境
      
  432.         CDC *pWindowDC = GetDC();  
  433.   
  434.         //1.用于映射屏幕的内存设备环境
      
  435.         //获取游戏窗口的大小用于下面设置内存位图的尺寸
      
  436.         CRect windowRect;  
  437.         GetClientRect(&windowRect);  
  438.         m_nWidth = windowRect.Width();  
  439.         m_nHeight = windowRect.Height();  
  440.   
  441.         //内存设备环境与屏幕设备环境关联(兼容)
      
  442.         m_memDC.CreateCompatibleDC(pWindowDC);  
  443.         //内存位图与与屏幕关联(兼容),大小为游戏窗口的尺寸
      
  444.         m_memBmp.CreateCompatibleBitmap(pWindowDC,m_nWidth,m_nHeight);  
  445.         //内存设备环境与内存位图关联,以便通过m_memDC在内存位图上作画
      
  446.         m_memDC.SelectObject(&m_memBmp);  
  447.   
  448.         //2.存储方块位图的内存资源
      
  449.         //内存设备环境与屏幕设备环境关联(兼容)
      
  450.         m_memRectDC.CreateCompatibleDC(pWindowDC);  
  451.         //相当于将外部位图rect.bmp动态载入m_hMemRectBmp中
      
  452.         m_hMemRectBmp=(HBITMAP
    )LoadImage(NULL,
    "rect.bmp"
    ,IMAGE_BITMAP,150,30,LR_LOADFROMFILE);  
  453.         //内存设备环境与内存位图关联,以便通过m_memDC在内存位图上作画
      
  454.         SelectObject(m_memRectDC.m_hDC, m_hMemRectBmp);   
  455.   
  456.       
  457.     //黑色的黑笔
      
  458.     m_pBlackPen  = new
     CPen(PS_SOLID,1,BLACK);  
  459.   
  460.     //画刷,
      
  461.     m_pGrayBrush  = new
     CBrush(RGB(0,60,0));  
  462.     m_pBlackBrush  = new
     CBrush(BLACK);  
  463.     }  
  464.   
  465. }  
  466.   
  467. void
     CSkyjuly_RecTTView::DCEnvClear()  
  468. {  
  469.     //设备环境
      
  470.     m_memDC.DeleteDC();  
  471.     m_memRectDC.DeleteDC();  
  472.     //位图资源
      
  473.     DeleteObject(m_memBmp);  
  474.     DeleteObject(m_hMemRectBmp);  
  475.   
  476.   
  477.     delete
    (m_pBlackPen);  
  478.     delete
    (m_pGrayBrush);  
  479.     delete
    (m_pBlackBrush);  
  480. }  
  481.   
  482.   
  483.   
  484. int
     CSkyjuly_RecTTView::OnCreate(LPCREATESTRUCT lpCreateStruct)   
  485. {  
  486.     if
     (CView::OnCreate(lpCreateStruct) == -1)  
  487.         return
     -1;  
  488.       
  489.   
  490.     //决定第一次掉下来的方块的样式
      
  491.     m_inextStatus = Random(7);  
  492.       
  493.     return
     0;  
  494. }  
  495.   
  496. int
     CSkyjuly_RecTTView::Random(
    int
     MaxNumber)  
  497. {  
  498.     //部下随机种子
      
  499.     srand( (unsigned)time( NULL ) );  
  500.     //产生随机数
      
  501.     int
     random = rand() % MaxNumber;  
  502.   
  503.     //保证非0
      
  504.     if
    (random == 0 )   
  505.         random++;  
  506.     return
     random;  
  507. }  
  508.   
  509.   
  510.   
  511. void
     CSkyjuly_RecTTView::RectDown()  
  512. {  
  513.     IsBottom();  
  514.     if
     (!m_isBottom)  
  515.     {  
  516.         //清除以前的方块
      
  517.         int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  518.         x1 = ActiveStatus[0][0];  
  519.         x2 = ActiveStatus[1][0];  
  520.         x3 = ActiveStatus[2][0];  
  521.         x4 = ActiveStatus[3][0];  
  522.         y1 = ActiveStatus[0][1];  
  523.         y2 = ActiveStatus[1][1];  
  524.         y3 = ActiveStatus[2][1];  
  525.         y4 = ActiveStatus[3][1];  
  526.         GameStatus[x1][y1]=MAP_STATE_EMPTY;  
  527.         GameStatus[x2][y2]=MAP_STATE_EMPTY;  
  528.         GameStatus[x3][y3]=MAP_STATE_EMPTY;  
  529.         GameStatus[x4][y4]=MAP_STATE_EMPTY;  
  530.         InvalidateCurrent();  
  531.   
  532.         //方块下落
      
  533.         ActiveStatus[0][0] += 1;  
  534.         ActiveStatus[1][0] += 1;  
  535.         ActiveStatus[2][0] += 1;  
  536.         ActiveStatus[3][0] += 1;  
  537.         GameStatus[x1+1][y1]=MAP_STATE_NOT_EMPTY;  
  538.         GameStatus[x2+1][y2]=MAP_STATE_NOT_EMPTY;  
  539.         GameStatus[x3+1][y3]=MAP_STATE_NOT_EMPTY;  
  540.         GameStatus[x4+1][y4]=MAP_STATE_NOT_EMPTY;  
  541.   
  542.         InvalidateCurrent();  
  543.     }  
  544. }  
  545.   
  546. void
     CSkyjuly_RecTTView::InvalidateCurrent()  
  547. {  
  548.     int
     i;    
  549.     for
     (i=0;i<4;i++)  
  550.     {  
  551.         CRect rect(m_iStartX+ActiveStatus[i][1]*m_iLarge,   
  552.                 m_iStartY+ActiveStatus[i][0]*m_iLarge,  
  553.                 m_iStartX+(ActiveStatus[i][1]+1)*m_iLarge+5,  
  554.                 m_iStartY+(ActiveStatus[i][0]+1)*m_iLarge);  
  555.             //InvalidateRect(&rect);
      
  556.             Invalidate(FALSE);  
  557.     }  
  558.   
  559. }  
  560.   
  561.   
  562.   
  563. void
     CSkyjuly_RecTTView::IsBottom()  
  564. {  
  565.     //到底有两种概念:1是已到底部,2是下面碰到了另外的方块
      
  566.     int
     x1,x2,x3,x4;  
  567.     int
     x,xx,yy,i;  
  568.   
  569.     x1 = ActiveStatus[0][0];  
  570.     x2 = ActiveStatus[1][0];  
  571.     x3 = ActiveStatus[2][0];  
  572.     x4 = ActiveStatus[3][0];  
  573.   
  574.   
  575.     //是否为底部的判断
      
  576.     //1。到达游戏区域的底部
      
  577.     //2。与接触面正下方的小方块区域为被占用状态
      
  578.     if
     (x1>=m_iRow-1 || x2>=m_iRow-1 || x3>=m_iRow-1 || x4>=m_iRow-1)  
  579.         m_isBottom = TRUE;  
  580.     else
      
  581.     {  
  582.         for
     (i=0;i<4;i++)  
  583.         {  
  584.             if
     (InterFace[m_currentRect][i] > -1)  
  585.             {//取当前下坠物有接触面的方块
      
  586.   
  587.                 //获取有接触面的小方块的编号
      
  588.                 x=InterFace[m_currentRect][i];  
  589.                 //根据编号获取ActiveStatus中该小方块的整下方的坐标
      
  590.                 xx=ActiveStatus[x][0]+1;  
  591.                 yy=ActiveStatus[x][1];  
  592.                 //判断该接触面整下方的小方块区域是否为被占用状态
      
  593.                 if
     (GameStatus[xx][yy]==MAP_STATE_NOT_EMPTY)  
  594.                     m_isBottom = TRUE;  
  595.             }  
  596.         }  
  597.     }  
  598.   
  599.     BOOL
     m_bIsSucced;  
  600.     int
     k,j;  
  601.     int
     m_iMuch=0; 
    //本次销掉的行数
      
  602.   
  603.     //计分规则:一次销掉一行,加100分,一次销掉两行,加400分,三行,900分
      
  604.     //例如销掉x行,则分数为:x*(x*100)
      
  605.   
  606.     if
     (m_isBottom)  
  607.     {  
  608.         //判断是否已得分
      
  609.         for
     (i=0;i<m_iRow;i++)  
  610.         {  
  611.             m_bIsSucced = TRUE;  
  612.             for
     (j=0;j<m_iCol;j++)  
  613.                 if
     (GameStatus[i][j]==MAP_STATE_EMPTY)  
  614.                     m_bIsSucced = FALSE;  
  615.               
  616.             //如果得分,则销掉此行
      
  617.             if
     (m_bIsSucced)  
  618.             {  
  619.                 for
     (k=i;k>0;k--)  
  620.                     for
     (j=0;j<m_iCol;j++)  
  621.                         GameStatus[k][j] = GameStatus[k-1][j];  
  622.                 //第1行清零
      
  623.                 for
     (j=0;j<m_iCol;j++)  
  624.                     GameStatus[0][j]=MAP_STATE_EMPTY;  
  625.   
  626.                 m_iMuch += 1;  
  627.             }  
  628.         }  
  629.           
  630.         if
     (m_iMuch>0)  
  631.         {  
  632.             m_iPerformance += m_iMuch * m_iMuch * 100;  
  633.             //刷新游戏区域
      
  634.             CRect rect1(m_iStartY, m_iStartX, m_iStartY+300, m_iStartX+360);  
  635.             //InvalidateRect(&rect1);
      
  636.               
  637.             //刷新分数区域
      
  638.             CRect rect2(m_iStartY+320, m_iStartX+180, m_iStartY+440, m_iStartX+200);  
  639.             //InvalidateRect(&rect2);
      
  640.             Invalidate(FALSE);  
  641.         }  
  642.   
  643.     }  
  644.   
  645.   
  646. }  
  647.   
  648.   
  649.   
  650. //映射下一个方快,显示下一个降落的方块
      
  651. void
     CSkyjuly_RecTTView::RectStatusToActiveStatus(
    int
     m_which)  
  652. {  
  653.     switch
    (m_which)  
  654.     {  
  655.     case
     1:     
  656.         ActiveStatus[0][0] = 0; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 1; ActiveStatus[1][1] = 5;  
  657.         ActiveStatus[2][0] = 2; ActiveStatus[2][1] = 5; ActiveStatus[3][0] = 3; ActiveStatus[3][1] = 5;  
  658.         break
    ;  
  659.     case
     2:      
  660.         ActiveStatus[0][0] = 0; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 1; ActiveStatus[1][1] = 5;  
  661.         ActiveStatus[2][0] = 0; ActiveStatus[2][1] = 6; ActiveStatus[3][0] = 1; ActiveStatus[3][1] = 6;  
  662.         break
    ;  
  663.     case
     3:  
  664.         ActiveStatus[0][0] = 1; ActiveStatus[0][1] = 4; ActiveStatus[1][0] = 0; ActiveStatus[1][1] = 5;  
  665.         ActiveStatus[2][0] = 1; ActiveStatus[2][1] = 5; ActiveStatus[3][0] = 1; ActiveStatus[3][1] = 6;  
  666.         break
    ;  
  667.     case
     4:  
  668.         ActiveStatus[0][0] = 0; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 1; ActiveStatus[1][1] = 5;  
  669.         ActiveStatus[2][0] = 1; ActiveStatus[2][1] = 6; ActiveStatus[3][0] = 2; ActiveStatus[3][1] = 6;  
  670.         break
    ;  
  671.     case
     5:  
  672.         ActiveStatus[0][0] = 1; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 2; ActiveStatus[1][1] = 5;  
  673.         ActiveStatus[2][0] = 0; ActiveStatus[2][1] = 6; ActiveStatus[3][0] = 1; ActiveStatus[3][1] = 6;  
  674.         break
    ;  
  675.     case
     6:  
  676.         ActiveStatus[0][0] = 0; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 0; ActiveStatus[1][1] = 6;  
  677.         ActiveStatus[2][0] = 1; ActiveStatus[2][1] = 6; ActiveStatus[3][0] = 2; ActiveStatus[3][1] = 6;  
  678.         break
    ;  
  679.     case
     7:  
  680.         ActiveStatus[0][0] = 0; ActiveStatus[0][1] = 5; ActiveStatus[1][0] = 1; ActiveStatus[1][1] = 5;  
  681.         ActiveStatus[2][0] = 2; ActiveStatus[2][1] = 5; ActiveStatus[3][0] = 0; ActiveStatus[3][1] = 6;  
  682.         break
    ;  
  683.     }  
  684.   
  685. }  
  686.   
  687. void
     CSkyjuly_RecTTView::OnTimer(
    UINT
     nIDEvent)   
  688. {  
  689.     //如果原来的方块已到底或游戏刚开始,则掉下一个新的方块
      
  690.     int
     i,j,k;  
  691.     if
     (m_isBottom)  
  692.     {  
  693.         //1.产生下一个随机下坠物
      
  694.         m_icurrentStatus = m_inextStatus;  
  695.         m_inextStatus = Random(7);  //得到下一次的方块样式
      
  696.     //  if (m_inextStatus==0) m_inextStatus++;
      
  697.   
  698.         //2.修改新的“下一下坠物”
      
  699.         RectStatusToNextStatus( m_inextStatus );  
  700.     //  CRect rect(m_iStartY+320, m_iStartX, m_iStartY+440, m_iStartX+160);
      
  701.     //  InvalidateRect(&rect);
      
  702.     //  Invalidate(FALSE);
      
  703.           
  704.         //3.将旧的“下一下坠物”用作当前使用
      
  705.         m_currentRect = m_icurrentStatus;     
  706.         //根据当前下坠物的形状去初始化激活状态下的下坠物坐标
      
  707.         RectStatusToActiveStatus( m_icurrentStatus );  
  708.         //将当前动态数组中的数据反映到大数组中
      
  709.         ActiveStatusToGameStatus();  
  710.         m_isBottom = FALSE;  
  711.   
  712.         //4.判断当前方块是否已到底
      
  713.         IsBottom();  
  714.   
  715.         //5.判断游戏是否已结束: 碰了底,且第1行有小方块
      
  716.         if
     (m_isBottom)  
  717.             for
     (i=0;i<m_iCol;i++)  
  718.                 if
     (GameStatus[0][i])  
  719.                 {  
  720.                     KillTimer(1);  
  721.                     AfxMessageBox("游戏已结束!"
    );  
  722.                     for
     (j=0;j<m_iRow;j++)  
  723.                         for
     (k=0;k<m_iCol;k++)  
  724.                             GameStatus[j][k]=0;  
  725.                     Invalidate(FALSE);  
  726.                     m_bGameEnd = TRUE;  
  727.                     break
    ;  
  728.                 }  
  729.   
  730.     }  
  731.     else
      
    //当前方块下降
      
  732.     {  
  733.         RectDown();  
  734.     }     
  735.     CView::OnTimer(nIDEvent);  
  736. }  
  737.   
  738.   
  739.   
  740. void
     CSkyjuly_RecTTView::ActiveStatusToGameStatus()  
  741. {  
  742.     int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  743.     x1 = ActiveStatus[0][0];  
  744.     x2 = ActiveStatus[1][0];  
  745.     x3 = ActiveStatus[2][0];  
  746.     x4 = ActiveStatus[3][0];  
  747.     y1 = ActiveStatus[0][1];  
  748.     y2 = ActiveStatus[1][1];  
  749.     y3 = ActiveStatus[2][1];  
  750.     y4 = ActiveStatus[3][1];  
  751.     GameStatus[x1][y1]=MAP_STATE_NOT_EMPTY;  
  752.     GameStatus[x2][y2]=MAP_STATE_NOT_EMPTY;  
  753.     GameStatus[x3][y3]=MAP_STATE_NOT_EMPTY;  
  754.     GameStatus[x4][y4]=MAP_STATE_NOT_EMPTY;  
  755. }  
  756.   
  757.   
  758. void
     CSkyjuly_RecTTView::RectStatusToNextStatus(
    int
     m_which)  
  759. {  
  760.     switch
    (m_which)  
  761.     {  
  762.     case
     1:  
  763.         NextStatus[0][0] = 0;   NextStatus[0][1] = 1;   NextStatus[1][0] = 1;   NextStatus[1][1] = 1;  
  764.         NextStatus[2][0] = 2;   NextStatus[2][1] = 1;   NextStatus[3][0] = 3;   NextStatus[3][1] = 1;  
  765.         break
    ;  
  766.     case
     2:  
  767.         NextStatus[0][0] = 0;   NextStatus[0][1] = 1;   NextStatus[1][0] = 1;   NextStatus[1][1] = 1;  
  768.         NextStatus[2][0] = 0;   NextStatus[2][1] = 2;   NextStatus[3][0] = 1;   NextStatus[3][1] = 2;  
  769.         break
    ;  
  770.     case
     3:  
  771.         NextStatus[0][0] = 1;   NextStatus[0][1] = 0;   NextStatus[1][0] = 0;   NextStatus[1][1] = 1;  
  772.         NextStatus[2][0] = 1;   NextStatus[2][1] = 1;   NextStatus[3][0] = 1;   NextStatus[3][1] = 2;  
  773.         break
    ;  
  774.     case
     4:  
  775.         NextStatus[0][0] = 0;   NextStatus[0][1] = 1;   NextStatus[1][0] = 1;   NextStatus[1][1] = 1;  
  776.         NextStatus[2][0] = 1;   NextStatus[2][1] = 2;   NextStatus[3][0] = 2;   NextStatus[3][1] = 2;  
  777.         break
    ;  
  778.     case
     5:  
  779.         NextStatus[0][0] = 1;   NextStatus[0][1] = 1;   NextStatus[1][0] = 2;   NextStatus[1][1] = 1;  
  780.         NextStatus[2][0] = 0;   NextStatus[2][1] = 2;   NextStatus[3][0] = 1;   NextStatus[3][1] = 2;  
  781.         break
    ;  
  782.     case
     6:  
  783.         NextStatus[0][0] = 0;   NextStatus[0][1] = 1;   NextStatus[1][0] = 0;   NextStatus[1][1] = 2;  
  784.         NextStatus[2][0] = 1;   NextStatus[2][1] = 2;   NextStatus[3][0] = 2;   NextStatus[3][1] = 2;  
  785.         break
    ;  
  786.     case
     7:  
  787.         NextStatus[0][0] = 0;   NextStatus[0][1] = 1;   NextStatus[1][0] = 1;   NextStatus[1][1] = 1;  
  788.         NextStatus[2][0] = 2;   NextStatus[2][1] = 1;   NextStatus[3][0] = 0;   NextStatus[3][1] = 2;  
  789.         break
    ;  
  790.     }  
  791.   
  792. }  
  793.   
  794. void
     CSkyjuly_RecTTView::RectArrow(
    int
     m_Type)  
  795. {  
  796.     //获取当前下坠物4个小方块的位置坐标
      
  797.     int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  798.     x1 = ActiveStatus[0][0];  
  799.     x2 = ActiveStatus[1][0];  
  800.     x3 = ActiveStatus[2][0];  
  801.     x4 = ActiveStatus[3][0];  
  802.     y1 = ActiveStatus[0][1];  
  803.     y2 = ActiveStatus[1][1];  
  804.     y3 = ActiveStatus[2][1];  
  805.     y4 = ActiveStatus[3][1];  
  806.   
  807.     //对不同的移动命令指示进行分类实现
      
  808.     switch
    (m_Type)  
  809.     {  
  810.     case
     LEFT:  
  811.         //对每种不同的移动命令指示特性作相应的可移动分析
      
  812.         if
     ( (ActiveStatus[0][1]>0) && IsLeftLimit() && !m_isBottom)  
  813.         {  
  814.             //清原来的方块
      
  815.             GameStatus[x1][y1]=MAP_STATE_EMPTY;  
  816.             GameStatus[x2][y2]=MAP_STATE_EMPTY;  
  817.             GameStatus[x3][y3]=MAP_STATE_EMPTY;  
  818.             GameStatus[x4][y4]=MAP_STATE_EMPTY;  
  819.   
  820.         //  InvalidateCurrent();
      
  821.             //添加新的移动后数据状态
      
  822.             ActiveStatus[0][1] -= 1;  
  823.             ActiveStatus[1][1] -= 1;  
  824.             ActiveStatus[2][1] -= 1;  
  825.             ActiveStatus[3][1] -= 1;  
  826.             GameStatus[x1][y1-1]=MAP_STATE_NOT_EMPTY;  
  827.             GameStatus[x2][y2-1]=MAP_STATE_NOT_EMPTY;  
  828.             GameStatus[x3][y3-1]=MAP_STATE_NOT_EMPTY;  
  829.             GameStatus[x4][y4-1]=MAP_STATE_NOT_EMPTY;  
  830.   
  831.             InvalidateCurrent();  
  832.         }  
  833.         break
    ;  
  834.   
  835.     case
     RIGHT:  
  836.         if
     ( (ActiveStatus[3][1]< m_iCol-1) && IsRightLimit() && !m_isBottom)  
  837.         {  
  838.             //清原来的方块
      
  839.             GameStatus[x1][y1]=MAP_STATE_EMPTY;  
  840.             GameStatus[x2][y2]=MAP_STATE_EMPTY;  
  841.             GameStatus[x3][y3]=MAP_STATE_EMPTY;  
  842.             GameStatus[x4][y4]=MAP_STATE_EMPTY;  
  843.   
  844.         //  InvalidateCurrent();
      
  845.             //添加新的移动后数据状态
      
  846.             ActiveStatus[0][1] += 1;  
  847.             ActiveStatus[1][1] += 1;  
  848.             ActiveStatus[2][1] += 1;  
  849.             ActiveStatus[3][1] += 1;  
  850.             GameStatus[x1][y1+1]=MAP_STATE_NOT_EMPTY;  
  851.             GameStatus[x2][y2+1]=MAP_STATE_NOT_EMPTY;  
  852.             GameStatus[x3][y3+1]=MAP_STATE_NOT_EMPTY;  
  853.             GameStatus[x4][y4+1]=MAP_STATE_NOT_EMPTY;  
  854.               
  855.             InvalidateCurrent();  
  856.         }  
  857.         break
    ;  
  858.   
  859.     case
     DOWN:  
  860.         RectDown();  
  861.         break
    ;  
  862.     }  
  863. }  
  864.   
  865.   
  866.   
  867. void
     CSkyjuly_RecTTView::OnKeyDown(
    UINT
     nChar, 
    UINT
     nRepCnt, 
    UINT
     nFlags)   
  868. {  
  869.     switch
    (nChar)  
  870.     {  
  871.     case
     VK_LEFT:  
  872.         RectArrow(LEFT);  
  873.         break
    ;  
  874.     case
     VK_RIGHT:  
  875.         RectArrow(RIGHT);  
  876.         break
    ;  
  877.     case
     VK_UP:  
  878.         RectChange();  
  879.         break
    ;  
  880.     case
     VK_DOWN:  
  881.         RectArrow(DOWN);  
  882.         break
    ;  
  883.     }  
  884.   
  885.     CView::OnKeyDown(nChar, nRepCnt, nFlags);  
  886. }  
  887.   
  888.   
  889.   
  890. BOOL
     CSkyjuly_RecTTView::IsLeftLimit()  
  891. {  
  892.     int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  893.     x1 = ActiveStatus[0][0];  
  894.     x2 = ActiveStatus[1][0];  
  895.     x3 = ActiveStatus[2][0];  
  896.     x4 = ActiveStatus[3][0];  
  897.     y1 = ActiveStatus[0][1];  
  898.     y2 = ActiveStatus[1][1];  
  899.     y3 = ActiveStatus[2][1];  
  900.     y4 = ActiveStatus[3][1];  
  901.   
  902.     //根据当前下坠物的具体形态,分析判断其是否有向左移动的空间
      
  903.     switch
    (m_currentRect)  
  904.     {        
  905.     // "1"字形形态类型,判断其四个方块的正左边都没有任何物件(空间没有被占据)
      
  906.     case
     1:  
  907.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1] || GameStatus[x4][y4-1])  
  908.             return
     FALSE;  
  909.         break
    ;  
  910.     case
     11:  
  911.         if
     (GameStatus[x1][y1-1])  
  912.             return
     FALSE;  
  913.         break
    ;  
  914.     case
     2:  
  915.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1])  
  916.             return
     FALSE;  
  917.         break
    ;  
  918.     case
     3:  
  919.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1])  
  920.             return
     FALSE;  
  921.         break
    ;  
  922.     case
     31:  
  923.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1])  
  924.             return
     FALSE;  
  925.         break
    ;  
  926.     case
     32:  
  927.         if
     (GameStatus[x1][y1-1] || GameStatus[x3][y3-1])  
  928.             return
     FALSE;  
  929.         break
    ;  
  930.     case
     33:  
  931.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x4][y4-1])  
  932.             return
     FALSE;  
  933.         break
    ;  
  934.     case
     4:  
  935.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x4][y4-1])  
  936.             return
     FALSE;  
  937.         break
    ;  
  938.     case
     41:  
  939.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1])  
  940.             return
     FALSE;  
  941.         break
    ;  
  942.     case
     5:  
  943.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1])  
  944.             return
     FALSE;  
  945.         break
    ;  
  946.     case
     51:  
  947.         if
     (GameStatus[x1][y1-1] || GameStatus[x3][y3-1])  
  948.             return
     FALSE;  
  949.         break
    ;  
  950.     case
     6:  
  951.         if
     (GameStatus[x1][y1-1] || GameStatus[x3][y3-1] || GameStatus[x4][y4-1])  
  952.             return
     FALSE;  
  953.         break
    ;  
  954.     case
     61:  
  955.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1])  
  956.             return
     FALSE;  
  957.         break
    ;  
  958.     case
     62:  
  959.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1])  
  960.             return
     FALSE;  
  961.         break
    ;  
  962.     case
     63:  
  963.         if
     (GameStatus[x1][y1-1] || GameStatus[x3][y3-1])  
  964.             return
     FALSE;  
  965.         break
    ;  
  966.     case
     7:  
  967.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1])  
  968.             return
     FALSE;  
  969.         break
    ;  
  970.     case
     71:  
  971.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1])  
  972.             return
     FALSE;  
  973.         break
    ;  
  974.     case
     72:  
  975.         if
     (GameStatus[x1][y1-1] || GameStatus[x2][y2-1] || GameStatus[x3][y3-1])  
  976.             return
     FALSE;  
  977.         break
    ;  
  978.     case
     73:  
  979.         if
     (GameStatus[x1][y1-1] || GameStatus[x4][y4-1])  
  980.             return
     FALSE;  
  981.         break
    ;  
  982.     }  
  983.   
  984.     return
     TRUE;  
  985.   
  986. }  
  987.   
  988.   
  989. BOOL
     CSkyjuly_RecTTView::IsRightLimit()  
  990. {  
  991. int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  992.     x1 = ActiveStatus[0][0];  
  993.     x2 = ActiveStatus[1][0];  
  994.     x3 = ActiveStatus[2][0];  
  995.     x4 = ActiveStatus[3][0];  
  996.     y1 = ActiveStatus[0][1];  
  997.     y2 = ActiveStatus[1][1];  
  998.     y3 = ActiveStatus[2][1];  
  999.     y4 = ActiveStatus[3][1];  
  1000.       
  1001.     switch
    (m_currentRect)  
  1002.     {  
  1003.     case
     1:  
  1004.         if
     (GameStatus[x1][y1+1] || GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1005.             return
     FALSE;  
  1006.         break
    ;  
  1007.     case
     11:  
  1008.         if
     (GameStatus[x4][y4+1])  
  1009.             return
     FALSE;  
  1010.         break
    ;  
  1011.     case
     2:  
  1012.         if
     (GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1013.             return
     FALSE;  
  1014.         break
    ;  
  1015.     case
     3:  
  1016.         if
     (GameStatus[x2][y2+1] || GameStatus[x4][y4+1])  
  1017.             return
     FALSE;  
  1018.         break
    ;  
  1019.     case
     31:  
  1020.         if
     (GameStatus[x1][y1+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1021.             return
     FALSE;  
  1022.         break
    ;  
  1023.     case
     32:  
  1024.         if
     (GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1025.             return
     FALSE;  
  1026.         break
    ;  
  1027.     case
     33:  
  1028.         if
     (GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1029.             return
     FALSE;  
  1030.         break
    ;  
  1031.     case
     4:  
  1032.         if
     (GameStatus[x1][y1+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1033.             return
     FALSE;  
  1034.         break
    ;  
  1035.     case
     41:  
  1036.         if
     (GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1037.             return
     FALSE;  
  1038.         break
    ;  
  1039.     case
     5:  
  1040.         if
     (GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1041.             return
     FALSE;  
  1042.         break
    ;  
  1043.     case
     51:  
  1044.         if
     (GameStatus[x2][y2+1] || GameStatus[x4][y4+1])  
  1045.             return
     FALSE;  
  1046.         break
    ;  
  1047.     case
     6:  
  1048.         if
     (GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1049.             return
     FALSE;  
  1050.         break
    ;  
  1051.     case
     61:  
  1052.         if
     (GameStatus[x2][y2+1] || GameStatus[x4][y4+1])  
  1053.             return
     FALSE;  
  1054.         break
    ;  
  1055.     case
     62:  
  1056.         if
     (GameStatus[x1][y1+1] || GameStatus[x2][y2+1] || GameStatus[x4][y4+1])  
  1057.             return
     FALSE;  
  1058.         break
    ;  
  1059.     case
     63:  
  1060.         if
     (GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1061.             return
     FALSE;  
  1062.         break
    ;  
  1063.     case
     7:  
  1064.         if
     (GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1065.             return
     FALSE;  
  1066.         break
    ;  
  1067.     case
     71:  
  1068.         if
     (GameStatus[x1][y1+1] || GameStatus[x4][y4+1])  
  1069.             return
     FALSE;  
  1070.         break
    ;  
  1071.     case
     72:  
  1072.         if
     (GameStatus[x2][y2+1] || GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1073.             return
     FALSE;  
  1074.         break
    ;  
  1075.     case
     73:  
  1076.         if
     (GameStatus[x3][y3+1] || GameStatus[x4][y4+1])  
  1077.             return
     FALSE;  
  1078.         break
    ;  
  1079.     }  
  1080.   
  1081.     return
     TRUE;  
  1082.   
  1083. }  
  1084.   
  1085. void
     CSkyjuly_RecTTView::RectChange()  
  1086. {  
  1087.   
  1088. //先预先变形,然后判断变形后的方块是否有空间,如有足够空间,则进行实际变形,否则不变
      
  1089.     int
     xx1,xx2,xx3,xx4,yy1,yy2,yy3,yy4;  
  1090.     int
     m_lscurrentRect;  
  1091.       
  1092.     CString lsStr;  
  1093.       
  1094.     int
     x1,x2,x3,x4,y1,y2,y3,y4;  
  1095.     x1 = ActiveStatus[0][0];  
  1096.     x2 = ActiveStatus[1][0];  
  1097.     x3 = ActiveStatus[2][0];  
  1098.     x4 = ActiveStatus[3][0];  
  1099.     y1 = ActiveStatus[0][1];  
  1100.     y2 = ActiveStatus[1][1];  
  1101.     y3 = ActiveStatus[2][1];  
  1102.     y4 = ActiveStatus[3][1];  
  1103.   
  1104.     //变形后位置在数组中的存放顺序仍需遵循先左后右,在同一列中先上后下
      
  1105.     xx1=x1; xx2=x2; xx3=x3; xx4=x4; yy1=y1; yy2=y2; yy3=y3; yy4=y4;  
  1106.     switch
    (m_currentRect)  
  1107.     {  
  1108.     case
     1:  
  1109.         xx1=x1+1; yy1=y1-1; xx3=x3-1; yy3=y3+1; xx4=x4-2; yy4=y4+2;  
  1110.         m_lscurrentRect = 11;  
  1111.         break
    ;  
  1112.     case
     11:  
  1113.         xx1=x1-1; yy1=y1+1; xx3=x3+1; yy3=y3-1; xx4=x4+2; yy4=y4-2;  
  1114.         m_lscurrentRect = 1;  
  1115.         break
    ;  
  1116.     case
     2:  
  1117.         m_lscurrentRect=2;   
  1118.         break
    ;  
  1119.     case
     3:  
  1120.         xx1=x1-2; yy1=y1+1; xx4=x4-1; yy4=y4;  
  1121.         m_lscurrentRect = 31;  
  1122.         break
    ;  
  1123.     case
     31:  
  1124.         xx1=x1+1; yy1=y1-1;   
  1125.         m_lscurrentRect = 32;  
  1126.         break
    ;  
  1127.     case
     32:  
  1128.         xx1=x1+1; yy1=y1; xx4=x4+2; yy4=y4-1;  
  1129.         m_lscurrentRect=33;  
  1130.         break
    ;  
  1131.     case
     33:  
  1132.         xx4=x4-1; yy4=y4+1;  
  1133.         m_lscurrentRect=3;  
  1134.         break
    ;  
  1135.     case
     4:  
  1136.         xx1=x1+2; yy1=y1-1; xx3=x3+1; yy3=y3-1; xx4=x4-1;  
  1137.         m_lscurrentRect = 41;  
  1138.         break
    ;  
  1139.     case
     41:  
  1140.         xx1=x1-2; yy1=y1+1; xx3=x3-1; yy3=y3+1; xx4=x4+1;  
  1141.         m_lscurrentRect = 4;  
  1142.         break
    ;  
  1143.     case
     5:  
  1144.         xx1=x1-1; xx2=x2-2; yy2=y2+1; xx3=x3+1; yy4=y4+1;  
  1145.         m_lscurrentRect = 51;  
  1146.         break
    ;  
  1147.     case
     51:  
  1148.         xx1=x1+1; xx2=x2+2; yy2=y2-1; xx3=x3-1; yy4=y4-1;  
  1149.         m_lscurrentRect = 5;  
  1150.         break
    ;  
  1151.     case
     6:  
  1152.         xx2=x1+1; yy2=y2-1; xx3=x3-1; xx4=x4-2; yy4 = yy4+1;  
  1153.         m_lscurrentRect = 61;  
  1154.         break
    ;  
  1155.     case
     61:  
  1156.         xx3=x3+2; yy3=y3-1; xx4=x4+2; yy4=y4-1;  
  1157.         m_lscurrentRect = 62;  
  1158.         break
    ;  
  1159.     case
     62:  
  1160.         xx1=x1+1; yy1=y1-1; xx3=x3-2; yy3=y3+1; xx4=x4-1;  
  1161.         m_lscurrentRect = 63;  
  1162.         break
    ;  
  1163.     case
     63:  
  1164.         xx1=x1-2; yy1=y1+1; xx2=x2-2; yy2=y2+1;  
  1165.         m_lscurrentRect = 6;  
  1166.         break
    ;  
  1167.     case
     7:  
  1168.         xx3=x3-1; yy3=y3+1; xx4=x4+1; yy4=y4+1;  
  1169.         m_lscurrentRect = 71;  
  1170.         break
    ;  
  1171.     case
     71:  
  1172.         xx1=x1+2; xx2=x2-1; yy2=y2+1; xx4=x4+1; yy4=y4-1;  
  1173.         m_lscurrentRect = 72;  
  1174.         break
    ;  
  1175.     case
     72:  
  1176.         xx1=x1-2; xx3=x3-1; yy3=y3+1; xx4=x4-1; yy4=y4+1;  
  1177.         m_lscurrentRect = 73;  
  1178.         break
    ;  
  1179.     case
     73:  
  1180.         xx2=x2+1; yy2=y2-1; xx3=x3+2; yy3=y3-2; xx4=x4-1; yy4=y4-1;  
  1181.         m_lscurrentRect = 7;  
  1182.         break
    ;  
  1183.     }  
  1184.   
  1185.     //如果变形后所在的区域内无其他方块,则表示有足够空间,可以变形
      
  1186.     //且不能超越边界
      
  1187.     GameStatus[x1][y1] = MAP_STATE_EMPTY;  
  1188.     GameStatus[x2][y2] = MAP_STATE_EMPTY;  
  1189.     GameStatus[x3][y3] = MAP_STATE_EMPTY;  
  1190.     GameStatus[x4][y4] = MAP_STATE_EMPTY;  
  1191.     if
     (GameStatus[xx1][yy1]==MAP_STATE_EMPTY &&  
  1192.         GameStatus[xx2][yy2]==MAP_STATE_EMPTY &&  
  1193.         GameStatus[xx3][yy3]==MAP_STATE_EMPTY &&   
  1194.         GameStatus[xx4][yy4]==MAP_STATE_EMPTY   
  1195.         && yy1>=0 && yy4<=m_iCol-1   
  1196.         && !(xx1<0 || xx2<0 || xx3<0 || xx4<0)   
  1197.         && !(xx1>m_iRow-1 || xx2>m_iRow-1 || xx3>m_iRow-1 || xx4>m_iRow-1) )  
  1198.     {  
  1199.         InvalidateCurrent();  
  1200.   
  1201.         ActiveStatus[0][0]=xx1;  
  1202.         ActiveStatus[1][0]=xx2;  
  1203.         ActiveStatus[2][0]=xx3;  
  1204.         ActiveStatus[3][0]=xx4;  
  1205.         ActiveStatus[0][1]=yy1;  
  1206.         ActiveStatus[1][1]=yy2;  
  1207.         ActiveStatus[2][1]=yy3;  
  1208.         ActiveStatus[3][1]=yy4;  
  1209.   
  1210.         GameStatus[xx1][yy1] = MAP_STATE_NOT_EMPTY;  
  1211.         GameStatus[xx2][yy2] = MAP_STATE_NOT_EMPTY;  
  1212.         GameStatus[xx3][yy3] = MAP_STATE_NOT_EMPTY;  
  1213.         GameStatus[xx4][yy4] = MAP_STATE_NOT_EMPTY;  
  1214.   
  1215.         InvalidateCurrent();  
  1216.   
  1217.         //改变形状代码
      
  1218.         m_currentRect = m_lscurrentRect;  
  1219.     }  
  1220.     else
      
  1221.     {//恢复原来状态
      
  1222.         GameStatus[x1][y1] = MAP_STATE_NOT_EMPTY;  
  1223.         GameStatus[x2][y2] = MAP_STATE_NOT_EMPTY;  
  1224.         GameStatus[x3][y3] = MAP_STATE_NOT_EMPTY;  
  1225.         GameStatus[x4][y4] = MAP_STATE_NOT_EMPTY;  
  1226.     }  
  1227.   
  1228.     //判断是否已到底
      
  1229.     IsBottom();  

//给的注释已经够详尽了,我就不再写多余的分析了。

//July、2010/10月。

Dlg.h文件。

  1. #if !defined(AFX_OPTIONDLG_H__570435A5_9237_4DE0_8215_48D075E106AD__INCLUDED_)
      
  2. #define AFX_OPTIONDLG_H__570435A5_9237_4DE0_8215_48D075E106AD__INCLUDED_
      
  3.   
  4. #if _MSC_VER > 1000
      
  5. #pragma once
      
  6. #endif // _MSC_VER > 1000
      
  7. // OptionDlg.h : header file
      
  8. //
      
  9.   
  10.   
  11. /////////////////////////////////////////////////////////////////////////////
      
  12. // COptionDlg dialog
      
  13.   
  14. class
     COptionDlg : 
    public
     CDialog  
  15. {  
  16. // Construction
      
  17. public
    :  
  18.     int
     m_iBlockStyle;  
  19.     int
     m_iLevel;  
  20.     int
     m_iArea;  
  21.     COptionDlg(int
     m_iArea, 
    int
     m_iLevel,
    int
     m_iBlockStyle, 
    BOOL
     m_bMusic,
    BOOL
     m_bDrawGrid, CWnd* pParent = NULL);  
  22.   
  23. // Dialog Data
      
  24.     //{{AFX_DATA(COptionDlg)
      
  25.     enum
     { IDD = IDD_DLG_OPTION };  
  26.     BOOL
        m_bDrawGrid;  
  27.     BOOL
        m_bMusic;  
  28.     //}}AFX_DATA
      
  29.   
  30.   
  31. // Overrides
      
  32.     // ClassWizard generated virtual function overrides
      
  33.     //{{AFX_VIRTUAL(COptionDlg)
      
  34.     protected
    :  
  35.     virtual
     
    void
     DoDataExchange(CDataExchange* pDX);    
    // DDX/DDV support
      
  36.     //}}AFX_VIRTUAL
      
  37.   
  38. // Implementation
      
  39. protected
    :  
  40.     int
     m_oldArea;  
  41.     int
     m_oldLevel;  
  42.     int
     m_oldBlockSytle;  
  43.   
  44.     BOOL
     m_oldMusic;  
  45.     BOOL
     m_oldDrawGrid;  
  46.   
  47.   
  48.     // Generated message map functions
      
  49.     //{{AFX_MSG(COptionDlg)
      
  50.     afx_msg void
     OnCheckGrid();  
  51.     virtual
     
    void
     OnOK();  
  52.     virtual
     
    BOOL
     OnInitDialog();  
  53.     afx_msg int
     OnCreate(LPCREATESTRUCT lpCreateStruct);  
  54.     afx_msg void
     OnGameOption();  
  55.     //}}AFX_MSG
      
  56.     DECLARE_MESSAGE_MAP()  
  57. };  
  58.   
  59. //{{AFX_INSERT_LOCATION}}
      
  60. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
      
  61.   
  62. #endif // !defined(AFX_OPTIONDLG_H__570435A5_9237_4DE0_8215_48D075E106AD__INCLUDED_)
      

Dlg.cpp文件。

  1. // OptionDlg.cpp : implementation file
      
  2. //
      
  3.   
  4. #include "stdafx.h"
      
  5. #include "skyjuly_RecTT.h"
      
  6. #include "OptionDlg.h"
      
  7.   
  8. #ifdef _DEBUG
      
  9. #define new DEBUG_NEW
      
  10. #undef THIS_FILE
      
  11. static
     
    char
     THIS_FILE[] = __FILE__;  
  12. #endif
      
  13.   
  14. /////////////////////////////////////////////////////////////////////////////
      
  15. // COptionDlg dialog
      
  16.   
  17.   
  18. COptionDlg::COptionDlg(int
     m_iArea, 
    int
     m_iLevel, 
    int
     m_iBlockStyle,
    BOOL
     m_bMusic, 
    BOOL
     m_bDrawGrid, CWnd* pParent 
    /*=NULL*/
    )  
  19.     : CDialog(COptionDlg::IDD, pParent)  
  20. {  
  21.     //{{AFX_DATA_INIT(COptionDlg)
      
  22.     m_bDrawGrid = FALSE;  
  23.     m_bMusic = FALSE;  
  24.     //}}AFX_DATA_INIT
      
  25. }  
  26.   
  27.   
  28. void
     COptionDlg::DoDataExchange(CDataExchange* pDX)  
  29. {  
  30.     CDialog::DoDataExchange(pDX);  
  31.     //{{AFX_DATA_MAP(COptionDlg)
      
  32.     DDX_Check(pDX, IDC_CHECK_GRID, m_bDrawGrid);  
  33.     DDX_Check(pDX, IDC_CHECK_MUSIC, m_bMusic);  
  34.     //}}AFX_DATA_MAP
      
  35. }  
  36.   
  37.   
  38. BEGIN_MESSAGE_MAP(COptionDlg, CDialog)  
  39.     //{{AFX_MSG_MAP(COptionDlg)
      
  40.     ON_BN_CLICKED(IDC_CHECK_GRID, OnCheckGrid)  
  41.     ON_WM_CREATE()  
  42.     ON_COMMAND(ID_GAME_OPTION, OnGameOption)  
  43.     //}}AFX_MSG_MAP
      
  44. END_MESSAGE_MAP()  
  45.   
  46. /////////////////////////////////////////////////////////////////////////////
      
  47. // COptionDlg message handlers
      
  48.   
  49. void
     COptionDlg::OnCheckGrid()   
  50. {  
  51.     // TODO: Add your control notification handler code here
      
  52.       
  53. }  
  54.   
  55. void
     COptionDlg::OnOK()   
  56. {  
  57.     // TODO: Add extra validation here
      
  58.       
  59.     CDialog::OnOK();  
  60. }  
  61.   
  62. BOOL
     COptionDlg::OnInitDialog()   
  63. {  
  64.     CDialog::OnInitDialog();  
  65.       
  66.     // TODO: Add extra initialization here
      
  67.       
  68.     return
     TRUE;  
    // return TRUE unless you set the focus to a control
      
  69.                   // EXCEPTION: OCX Property Pages should return FALSE
      
  70. }  
  71.   
  72. int
     COptionDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)   
  73. {  
  74.     if
     (CDialog::OnCreate(lpCreateStruct) == -1)  
  75.         return
     -1;  
  76.       
  77.     // TODO: Add your specialized creation code here
      
  78.       
  79.     return
     0;  
  80. }  
  81.   
  82. void
     COptionDlg::OnGameOption()   
  83. {  
  84.     // TODO: Add your command handler code here
      
  85.       
  86. }  

//至此,大部分源码,已经贴出,欢迎各位 就俄罗斯方块算法交流指正。

//曾经 单单玩这个游戏,便 玩了好几个月。;-)。

抱歉!评论已关闭.