RussianGameDlg.cpp
上传用户:clj987822
上传日期:2022-04-25
资源大小:13296k
文件大小:70k
源码类别:

其他智力游戏

开发平台:

Visual C++

  1. // RussianGameDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "RussianGame.h"
  5. #include "RussianGameDlg.h"
  6. #include "HeroDlg.h"
  7. #include "NameDlg.h"
  8. #include "mmsystem.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. #define LeftMargin 20
  15. #define TopMargin 20
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAboutDlg dialog used for App About
  18. class CAboutDlg : public CDialog
  19. {
  20. public:
  21. CAboutDlg();
  22. // Dialog Data
  23. //{{AFX_DATA(CAboutDlg)
  24. enum { IDD = IDD_ABOUTBOX };
  25. //}}AFX_DATA
  26. // ClassWizard generated virtual function overrides
  27. //{{AFX_VIRTUAL(CAboutDlg)
  28. protected:
  29. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  30. //}}AFX_VIRTUAL
  31. // Implementation
  32. protected:
  33. //{{AFX_MSG(CAboutDlg)
  34. //}}AFX_MSG
  35. DECLARE_MESSAGE_MAP()
  36. };
  37. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  38. {
  39. //{{AFX_DATA_INIT(CAboutDlg)
  40. //}}AFX_DATA_INIT
  41. }
  42. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAboutDlg)
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  49. //{{AFX_MSG_MAP(CAboutDlg)
  50. // No message handlers
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CRussianGameDlg dialog
  55. CRussianGameDlg::CRussianGameDlg(CWnd* pParent /*=NULL*/)
  56. : CDialog(CRussianGameDlg::IDD, pParent)
  57. {
  58. //{{AFX_DATA_INIT(CRussianGameDlg)
  59. //}}AFX_DATA_INIT
  60. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  61. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  62. m_iScore=0;
  63. m_iSp=1;
  64. m_iLine=0;
  65. pause=FALSE;
  66. gameover=TRUE;
  67. FlagSound=FALSE;
  68. board.game =FALSE;
  69. board.level =1;
  70. board.scroe =0;
  71. board.pic[0].LoadBitmap(IDB_BITMAP0);
  72. board.pic[1].LoadBitmap(IDB_BITMAP1); 
  73. rect.left =LeftMargin;
  74. rect.top =TopMargin;
  75. rect.right =LeftMargin+202;
  76. rect.bottom =TopMargin+362;
  77. picnext[1].LoadBitmap(IDB_PIC1);
  78. picnext[2].LoadBitmap(IDB_PIC2);
  79. picnext[3].LoadBitmap(IDB_PIC3);
  80. picnext[4].LoadBitmap(IDB_PIC4);
  81. picnext[5].LoadBitmap(IDB_PIC5);
  82. picnext[6].LoadBitmap(IDB_PIC6);
  83. picnext[7].LoadBitmap(IDB_PIC7);
  84. int i,j;
  85. for(i=0;i<11;i++)
  86. for(j=0;j<19;j++)
  87. board.square[i][j]=0; 
  88. scorenum[0]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum1"),500);
  89. scorenum[1]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum2"),500);
  90. scorenum[2]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum3"),500);
  91. scorenum[3]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum4"),500);
  92. scorenum[4]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum5"),500);
  93. scorename[0]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename1"),_T("无名英雄"));
  94. scorename[1]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename2"),_T("无名英雄"));
  95. scorename[2]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename3"),_T("无名英雄"));
  96. scorename[3]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename4"),_T("无名英雄"));
  97. scorename[4]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename5"),_T("无名英雄"));
  98. }
  99. void CRussianGameDlg::DoDataExchange(CDataExchange* pDX)
  100. {
  101. CDialog::DoDataExchange(pDX);
  102. //{{AFX_DATA_MAP(CRussianGameDlg)
  103. DDX_Control(pDX, IDC_SOUND, m_Sound);
  104. DDX_Control(pDX, IDC_EXIT, m_Exit);
  105. DDX_Control(pDX, IDC_START, m_Start);
  106. DDX_Control(pDX, IDC_SPADD, m_SpAdd);
  107. DDX_Control(pDX, IDC_PAUSE, m_Pause);
  108. DDX_Control(pDX, IDC_LINEADD, m_LineAdd);
  109. //}}AFX_DATA_MAP
  110. }
  111. BEGIN_MESSAGE_MAP(CRussianGameDlg, CDialog)
  112. //{{AFX_MSG_MAP(CRussianGameDlg)
  113. ON_WM_SYSCOMMAND()
  114. ON_WM_PAINT()
  115. ON_WM_QUERYDRAGICON()
  116. ON_BN_CLICKED(IDC_SPADD, OnSpadd)
  117. ON_BN_CLICKED(IDC_EXIT, OnExit)
  118. ON_BN_CLICKED(IDC_START, OnStart)
  119. ON_WM_TIMER()
  120. ON_WM_KEYDOWN()
  121. ON_BN_CLICKED(IDC_PAUSE, OnPause)
  122. ON_BN_CLICKED(IDC_LINEADD, OnLineadd)
  123. ON_BN_CLICKED(IDC_SOUND, OnSound)
  124. //}}AFX_MSG_MAP
  125. END_MESSAGE_MAP()
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CRussianGameDlg message handlers
  128. BOOL CRussianGameDlg::OnInitDialog()
  129. {
  130. CDialog::OnInitDialog();
  131. // Add "About..." menu item to system menu.
  132. // IDM_ABOUTBOX must be in the system command range.
  133. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  134. ASSERT(IDM_ABOUTBOX < 0xF000);
  135.  CMenu* pSysMenu = GetSystemMenu(FALSE);
  136. if (pSysMenu != NULL)
  137. {
  138. CString strAboutMenu;
  139. strAboutMenu.LoadString(IDS_ABOUTBOX);
  140. if (!strAboutMenu.IsEmpty())
  141. {
  142. pSysMenu->AppendMenu(MF_SEPARATOR);
  143. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  144. }
  145. }
  146. // Set the icon for this dialog.  The framework does this automatically
  147. //  when the application's main window is not a dialog
  148. SetIcon(m_hIcon, TRUE); // Set big icon
  149. SetIcon(m_hIcon, FALSE); // Set small icon
  150. RECT rect;
  151. GetWindowRect(&rect);
  152. int cx=rect.right -rect.left ;
  153. int cy=rect.bottom -rect.top ;
  154. POINT pos[9];
  155. pos[0].x =0;
  156. pos[0].y = 0;
  157. pos[1].x = cx;
  158. pos[1].y = 0;
  159. pos[2].x = cx;
  160. pos[2].y = cy - 20;
  161. pos[3].x = cx - 25;
  162. pos[3].y = cy - 20;
  163. pos[4].x = cx - 50;
  164. pos[4].y = cy;
  165. pos[5].x = 50;
  166. pos[5].y = cy;
  167. pos[6].x = 25;
  168. pos[6].y = cy - 20;
  169. pos[7].x = 0;
  170. pos[7].y = cy - 20;
  171. pos[8] = pos[0];
  172. HRGN hrgn;//,hrgn1;
  173. hrgn=CreatePolygonRgn(pos,9,2);
  174. CDC *pDC=GetDC();
  175. // SetBkMode(pDC->m_hDC,TRANSPARENT);
  176. // pDC->BeginPath();
  177. // pDC->TextOut(cx/2-20,cy-10,"英雄无敌",8);
  178. // pDC->EndPath();
  179. // hrgn1=PathToRegion(pDC->m_hDC);
  180. //CombineRgn(hrgn,hrgn,hrgn1,RGN_DIFF);
  181. // SetWindowRgn(hrgn,TRUE);
  182. m_SpAdd.SetIcon(IDI_ICONADD);
  183. m_SpAdd.AddToolTip(_T("水平"));
  184. m_SpAdd.SetBtnCursor(IDC_HAND);
  185. m_SpAdd.SetActiveFgColor(RGB(0,0,255));
  186. m_Start.SetIcon(IDI_ICONSTART);
  187. m_Start.AddToolTip(_T("开始"));
  188. m_Start.SetBtnCursor(IDC_HAND);
  189. m_Start.SetActiveFgColor(RGB(0,0,255));
  190. m_Pause.SetIcon(IDI_ICONPAUSE);
  191. m_Pause.AddToolTip(_T("暂停"));
  192. m_Pause.SetBtnCursor(IDC_HAND);
  193. m_Pause.SetActiveFgColor(RGB(0,0,255));
  194. m_Exit.SetIcon(IDI_ICONEXIT);
  195. m_Exit.AddToolTip(_T("退出"));
  196. m_Exit.SetBtnCursor(IDC_HAND);
  197. m_Exit.SetActiveFgColor(RGB(0,0,255));
  198. m_LineAdd.SetIcon(IDI_ICONADD);
  199. m_LineAdd.AddToolTip(_T("行数"));
  200. m_LineAdd.SetBtnCursor(IDC_HAND);
  201. m_LineAdd.SetActiveFgColor(RGB(0,0,255));
  202. m_Sound.SetIcon(IDI_ICONSOUND);
  203. m_Sound.AddToolTip(_T("声音"));
  204. m_Sound.SetBtnCursor(IDC_HAND);
  205. m_Sound.SetActiveFgColor(RGB(0,0,255));
  206. Score_num.Create(this,285,105,0,5);
  207. Sp_num.Create(this,305,157,0,2);
  208. Line_num.Create(this,305,243,0,2);
  209. //TODO: Add extra initialization here
  210. return TRUE;  // return TRUE  unless you set the focus to a control
  211. }
  212. void CRussianGameDlg::OnSysCommand(UINT nID, LPARAM lParam)
  213. {
  214. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  215. {
  216. CAboutDlg dlgAbout;
  217. dlgAbout.DoModal();
  218. }
  219. else
  220. {
  221. CDialog::OnSysCommand(nID, lParam);
  222. }
  223. }
  224. // If you add a minimize button to your dialog, you will need the code below
  225. //  to draw the icon.  For MFC applications using the document/view model,
  226. //  this is automatically done for you by the framework.
  227. void CRussianGameDlg::OnPaint() 
  228. {
  229. CPaintDC dc(this);
  230. if (IsIconic())
  231. {
  232.  // device context for painting
  233. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  234. // Center icon in client rectangle
  235. int cxIcon = GetSystemMetrics(SM_CXICON);
  236. int cyIcon = GetSystemMetrics(SM_CYICON);
  237. CRect rect;
  238. GetClientRect(&rect);
  239. int x = (rect.Width() - cxIcon + 1) / 2;
  240. int y = (rect.Height() - cyIcon + 1) / 2;
  241. // Draw the icon
  242. dc.DrawIcon(x, y, m_hIcon);
  243. }
  244. else
  245. {
  246. /*CDC memdc;
  247. CDC *pDC=GetDC();
  248. RECT rect;
  249. memdc.CreateCompatibleDC(pDC);
  250. GetClientRect(&rect);
  251. CBitmap bitmap;
  252. bitmap.LoadBitmap(IDB_BACKPIC);
  253. int cx=rect.right -rect.left ;
  254. int cy=rect.bottom -rect.top ;
  255. memdc.SelectObject(bitmap);
  256. pDC->BitBlt(0,0,cx,cy,&memdc,0,0,SRCCOPY);
  257. ReleaseDC(pDC);*/
  258. CBrush br(RGB(0,0,255));
  259. CRect rc=rect;
  260. dc.FrameRect(&rc,&br);
  261. rc.InflateRect(2,2);
  262. CBrush br1(RGB(0,255,0));
  263. dc.FrameRect(&rc,&br1);
  264. CBrush br2(RGB(255,0,0));
  265. rc.InflateRect(2,2);
  266. dc.FrameRect(&rc,&br2);
  267. br.DeleteObject();
  268. br1.DeleteObject();
  269. br2.DeleteObject();
  270. rc.SetRectEmpty();
  271. paintpic(&dc);
  272. Score_num.SetNumber(board.scroe);
  273. Sp_num.SetNumber(board.level);
  274. Line_num.SetNumber(m_iLine);
  275. CDialog::OnPaint();
  276. }
  277. }
  278. // The system calls this to obtain the cursor to display while the user drags
  279. //  the minimized window.
  280. HCURSOR CRussianGameDlg::OnQueryDragIcon()
  281. {
  282. return (HCURSOR) m_hIcon;
  283. }
  284. void CRussianGameDlg::checkforhighscore()
  285. {
  286. getscore();
  287. int n,j;
  288. for (n=0;n<5;n++)
  289. if(board.scroe >= scorenum[n])
  290. {
  291.     if(n<4)
  292. {
  293.         for(j=4;j>=n+1;j--)
  294. {
  295. scorenum[j] = scorenum[j - 1];
  296.             scorename[j] = scorename[j - 1];
  297. }
  298. }
  299.     CNameDlg name;
  300. name.DoModal();
  301. heroname=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("heroname"),_T("无名英雄"));
  302.     scorename[n] =heroname;
  303.     scorenum[n] = board.scroe;
  304.     writescore();
  305.     break;
  306. }
  307. return;
  308. }
  309. void CRussianGameDlg::getscore()
  310. {
  311. scorenum[0]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum1"),500);
  312. scorenum[1]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum2"),500);
  313. scorenum[2]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum3"),500);
  314. scorenum[3]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum4"),500);
  315. scorenum[4]=AfxGetApp()->GetProfileInt(_T("英雄榜"),_T("scorenum5"),500);
  316. scorename[0]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename1"),_T("无名英雄"));
  317. scorename[1]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename2"),_T("无名英雄"));
  318. scorename[2]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename3"),_T("无名英雄"));
  319. scorename[3]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename4"),_T("无名英雄"));
  320. scorename[4]=AfxGetApp()->GetProfileString(_T("英雄榜"),_T("scorename5"),_T("无名英雄"));
  321. }
  322. void CRussianGameDlg::drawpiece()
  323. {
  324. int i,curpiece;
  325. curpiece=board.curpiece ;
  326. switch  (curpiece)
  327. {
  328. case 1:
  329. {
  330.         for (i=4;i<=7;i++)
  331. {
  332.             if (board.square[i][1]!=0) gameover = TRUE;
  333.             board.square[i][1]=1;
  334.         }
  335. }
  336. break;
  337. case 2:
  338. {
  339.         if (board.square[4][1] != 0) gameover = TRUE;
  340.         board.square[4][1] = 1;
  341.         for(i = 4;i<=6;i++)
  342. {
  343.             if (board.square[i][2] != 0)gameover = TRUE;
  344.             board.square[i][2] = 1;
  345.         }
  346. }
  347. break;
  348. case 3:
  349. {
  350.         if (board.square[6][1] != 0) gameover = TRUE;
  351.         board.square[6][1] = 1;
  352.         for(i = 4;i<=6;i++)
  353. {
  354.             if (board.square[i][2] != 0) gameover = TRUE;
  355.             board.square[i][2] = 1;
  356.         }
  357. }
  358. break;
  359. case 4:
  360. {
  361.         for(i = 4;i<=5;i++)
  362. {
  363.             if (board.square[i][1] != 0) gameover = TRUE;
  364.             board.square[i][1] = 1;
  365.         }
  366.         for(i = 5;i<=6;i++)
  367. {
  368.             if (board.square[i][2] != 0) gameover = TRUE;
  369.             board.square[i][2] = 1;
  370. }
  371. }
  372. break;
  373. case 5:
  374. {
  375.         for(i = 5;i<=6;i++)
  376. {
  377.             if (board.square[i][1] != 0) gameover = TRUE;
  378.             board.square[i][1] = 1;
  379.         }
  380.         for(i = 4;i<=5;i++)
  381. {
  382.             if (board.square[i][2] != 0) gameover = TRUE;
  383.             board.square[i][2] = 1;
  384. }
  385. }
  386. break;
  387. case 6:
  388. {
  389.         if (board.square[5][1] != 0) gameover = TRUE;
  390.         board.square[5][1] = 1;
  391.         for(i = 4;i<=6;i++)
  392. {
  393.             if (board.square[i][2] != 0) gameover = TRUE;
  394.             board.square[i][2] = 1;
  395.         }
  396. }
  397. break;
  398. case 7:
  399. {
  400.         for(i = 5;i<=6;i++)
  401. {
  402.             if (board.square[i][1] != 0) gameover = TRUE;
  403.             board.square[i][1] = 1;
  404.         }
  405.         for(i = 5;i<=6;i++)
  406. {
  407.             if (board.square[i][2] != 0) gameover = TRUE;
  408.             board.square[i][2] = 1;
  409.         }
  410. }
  411. break;
  412. }
  413. return;
  414. }
  415. void CRussianGameDlg::movepiecedown()
  416. {
  417. int i,curpiece;
  418. curpiece=board.curpiece ;
  419. switch  (curpiece)
  420. {
  421. case 1:
  422. {
  423.             if (board.piecepos == 1)
  424. {
  425.                 if(board.piecey <= 17)
  426. {
  427.                     if(board.square[board.piecex - 1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0 && board.square[board.piecex +2][board.piecey + 1]== 0)
  428. {
  429.                         for(i = board.piecex - 1;i<=board.piecex + 2;i++)
  430. {
  431.                             board.square[i][board.piecey] = 0;
  432.                             board.square[i][board.piecey + 1] = 1;
  433.                         }
  434.                         board.piecey = board.piecey + 1;
  435.                     }
  436. else
  437.                         newpiece = TRUE;
  438.                 }
  439. else
  440.                     newpiece = TRUE;
  441. }
  442.             else if (board.piecepos== 2)
  443. {
  444.                 if (board.piecey <= 15)
  445. {
  446.                     if(board.square[board.piecex][board.piecey + 3]== 0)
  447. {
  448.                         board.square[board.piecex][board.piecey + 3] = 1;
  449.                         board.square[board.piecex][board.piecey -1] = 0;
  450.                         board.piecey = board.piecey + 1;
  451.                     }
  452. else
  453.                         newpiece = TRUE;
  454. }
  455.                 else
  456.                     newpiece = TRUE;
  457. }
  458. }
  459. break;
  460. case 2:
  461. {
  462.             if(board.piecepos == 1)
  463. {
  464.                 if(board.piecey <= 17)
  465. {
  466.                     if(board.square[board.piecex-1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  467. {
  468.                         board.square[board.piecex-1][board.piecey + 1]= 1;
  469.                         board.square[board.piecex][board.piecey + 1] = 1;
  470.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  471.                         board.square[board.piecex-1][board.piecey - 1] = 0;
  472.                         board.square[board.piecex][board.piecey] = 0;
  473.                         board.square[board.piecex+1][board.piecey] = 0;
  474.                         board.piecey = board.piecey + 1;
  475. }
  476.                     else
  477.                         newpiece = TRUE;
  478. }
  479.                 else
  480.                     newpiece = TRUE;
  481. }
  482.             else if(board.piecepos== 2)
  483. {
  484.                 if(board.piecey <= 16)
  485. {
  486.                     if( board.square[board.piecex][board.piecey + 2]== 0 && board.square[board.piecex + 1][board.piecey]== 0)
  487. {
  488.                         board.square[board.piecex][board.piecey + 2] = 1;
  489.                         board.square[board.piecex+1][board.piecey] = 1;
  490.                         board.square[board.piecex][board.piecey -1] = 0;
  491.                         board.square[board.piecex+1][board.piecey-1] = 0;
  492.                         board.piecey = board.piecey + 1;
  493. }
  494.                     else
  495.                         newpiece = TRUE;
  496. }
  497.                 else
  498.                     newpiece = TRUE;
  499. }
  500.             else if(board.piecepos == 3)
  501. {
  502.                 if(board.piecey <= 16)
  503. {
  504.                     if( board.square[board.piecex-1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey+1]== 0 && board.square[board.piecex+1][board.piecey+2]== 0)
  505. {
  506.                         board.square[board.piecex-1][board.piecey + 1] = 1;
  507.                         board.square[board.piecex][board.piecey+1] = 1;
  508. board.square[board.piecex+1][board.piecey + 2] = 1;
  509.                         board.square[board.piecex-1][board.piecey] = 0;
  510.                         board.square[board.piecex][board.piecey] = 0;
  511. board.square[board.piecex+1][board.piecey] = 0;
  512.                         board.piecey = board.piecey + 1;
  513. }
  514.                     else
  515.                         newpiece = TRUE;
  516. }
  517.                 else
  518.                     newpiece = TRUE;
  519. }
  520.             else if(board.piecepos== 4)
  521.             {
  522.                 if(board.piecey <= 16)
  523. {
  524.                     if( board.square[board.piecex-1][board.piecey + 2]== 0 && board.square[board.piecex][board.piecey+2]== 0)
  525. {
  526.                         board.square[board.piecex-1][board.piecey + 2] = 1;
  527.                         board.square[board.piecex][board.piecey+2] = 1;
  528.                         board.square[board.piecex][board.piecey -1] = 0;
  529.                         board.square[board.piecex-1][board.piecey+1] = 0;
  530.                         board.piecey = board.piecey + 1;
  531. }
  532.                     else
  533.                         newpiece = TRUE;
  534. }
  535.                 else
  536.                     newpiece = TRUE;
  537. }
  538. }
  539. break;
  540. case 3:
  541. {
  542.            if(board.piecepos == 1)
  543. {
  544.                 if(board.piecey <= 17)
  545. {
  546.                     if(board.square[board.piecex-1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  547. {
  548.                         board.square[board.piecex-1][board.piecey + 1]= 1;
  549.                         board.square[board.piecex][board.piecey + 1] = 1;
  550.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  551.                         board.square[board.piecex-1][board.piecey] = 0;
  552.                         board.square[board.piecex][board.piecey] = 0;
  553.                         board.square[board.piecex+1][board.piecey-1] = 0;
  554.                         board.piecey = board.piecey + 1;
  555. }
  556.                     else
  557.                         newpiece = TRUE;
  558. }
  559.                 else
  560.                     newpiece = TRUE;
  561. }
  562.             else if(board.piecepos== 2)
  563. {
  564.                 if(board.piecey <= 16)
  565. {
  566.                     if( board.square[board.piecex][board.piecey + 2]== 0 && board.square[board.piecex + 1][board.piecey+2]== 0)
  567. {
  568.                         board.square[board.piecex][board.piecey + 2] = 1;
  569.                         board.square[board.piecex+1][board.piecey+2] = 1;
  570.                         board.square[board.piecex][board.piecey -1] = 0;
  571.                         board.square[board.piecex+1][board.piecey+1] = 0;
  572.                         board.piecey = board.piecey + 1;
  573. }
  574.                     else
  575.                         newpiece = TRUE;
  576. }
  577.                 else
  578.                     newpiece = TRUE;
  579. }
  580.             else if(board.piecepos == 3)
  581. {
  582.                 if(board.piecey <= 16)
  583. {
  584.                     if( board.square[board.piecex-1][board.piecey + 2]== 0 && board.square[board.piecex][board.piecey+1]== 0 && board.square[board.piecex+1][board.piecey+1]== 0)
  585. {
  586.                         board.square[board.piecex-1][board.piecey + 2] = 1;
  587.                         board.square[board.piecex][board.piecey+1] = 1;
  588. board.square[board.piecex+1][board.piecey + 1] = 1;
  589.                         board.square[board.piecex-1][board.piecey] = 0;
  590.                         board.square[board.piecex][board.piecey] = 0;
  591. board.square[board.piecex+1][board.piecey] = 0;
  592.                         board.piecey = board.piecey + 1;
  593. }
  594.                     else
  595.                         newpiece = TRUE;
  596. }
  597.                 else
  598.                     newpiece = TRUE;
  599. }
  600.             else if(board.piecepos== 4)
  601.             {
  602.                 if(board.piecey <= 16)
  603. {
  604.                     if( board.square[board.piecex-1][board.piecey]== 0 && board.square[board.piecex][board.piecey+2]== 0)
  605. {
  606.                         board.square[board.piecex-1][board.piecey] = 1;
  607.                         board.square[board.piecex][board.piecey+2] = 1;
  608.                         board.square[board.piecex][board.piecey -1] = 0;
  609.                         board.square[board.piecex-1][board.piecey-1] = 0;
  610.                         board.piecey = board.piecey + 1;
  611. }
  612.                     else
  613.                         newpiece = TRUE;
  614. }
  615.                 else
  616.                     newpiece = TRUE;
  617. }
  618. }
  619. break;
  620. case 4:
  621. {
  622. if(board.piecepos == 1)
  623. {
  624.                 if(board.piecey <= 17)
  625. {
  626.                     if(board.square[board.piecex-1][board.piecey]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  627. {
  628.                         board.square[board.piecex-1][board.piecey]= 1;
  629.                         board.square[board.piecex][board.piecey + 1] = 1;
  630.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  631.                         board.square[board.piecex-1][board.piecey-1] = 0;
  632.                         board.square[board.piecex][board.piecey-1] = 0;
  633.                         board.square[board.piecex+1][board.piecey] = 0;
  634.                         board.piecey = board.piecey + 1;
  635. }
  636.                     else
  637.                         newpiece = TRUE;
  638. }
  639.                 else
  640.                     newpiece = TRUE;
  641. }
  642.             else if(board.piecepos== 2)
  643. {
  644.                 if(board.piecey <= 16)
  645. {
  646.                     if( board.square[board.piecex][board.piecey + 2]== 0 && board.square[board.piecex + 1][board.piecey+1]== 0)
  647. {
  648.                         board.square[board.piecex][board.piecey + 2] = 1;
  649.                         board.square[board.piecex+1][board.piecey+1] = 1;
  650.                         board.square[board.piecex][board.piecey] = 0;
  651.                         board.square[board.piecex+1][board.piecey-1] = 0;
  652.                         board.piecey = board.piecey + 1;
  653. }
  654.                     else
  655.                         newpiece = TRUE;
  656. }
  657.                 else
  658.                     newpiece = TRUE;
  659. }
  660. }
  661. break;
  662. case 5:
  663. {
  664.             if(board.piecepos == 1)
  665. {
  666.                 if(board.piecey <= 17)
  667. {
  668.                     if(board.square[board.piecex-1][board.piecey+1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey]== 0)
  669. {
  670.                         board.square[board.piecex-1][board.piecey+1]= 1;
  671.                         board.square[board.piecex][board.piecey + 1] = 1;
  672.                         board.square[board.piecex+1][board.piecey] = 1;
  673.                         board.square[board.piecex-1][board.piecey] = 0;
  674.                         board.square[board.piecex][board.piecey-1] = 0;
  675.                         board.square[board.piecex+1][board.piecey-1] = 0;
  676.                         board.piecey = board.piecey + 1;
  677. }
  678.                     else
  679.                         newpiece = TRUE;
  680. }
  681.                 else
  682.                     newpiece = TRUE;
  683. }
  684.             else if(board.piecepos== 2)
  685. {
  686.                 if(board.piecey <= 16)
  687. {
  688.                     if( board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex + 1][board.piecey+2]== 0)
  689. {
  690.                         board.square[board.piecex][board.piecey + 1] = 1;
  691.                         board.square[board.piecex+1][board.piecey+2] = 1;
  692.                         board.square[board.piecex][board.piecey-1] = 0;
  693.                         board.square[board.piecex+1][board.piecey] = 0;
  694.                         board.piecey = board.piecey + 1;
  695. }
  696.                     else
  697.                         newpiece = TRUE;
  698. }
  699.                 else
  700.                     newpiece = TRUE;
  701. }
  702. }
  703. break;
  704. case 6:
  705. {
  706. if(board.piecepos == 1)
  707. {
  708.                 if(board.piecey <= 17)
  709. {
  710.                     if(board.square[board.piecex-1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  711. {
  712.                         board.square[board.piecex-1][board.piecey + 1]= 1;
  713.                         board.square[board.piecex][board.piecey + 1] = 1;
  714.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  715.                         board.square[board.piecex-1][board.piecey] = 0;
  716.                         board.square[board.piecex][board.piecey-1] = 0;
  717.                         board.square[board.piecex+1][board.piecey] = 0;
  718.                         board.piecey = board.piecey + 1;
  719. }
  720.                     else
  721.                         newpiece = TRUE;
  722. }
  723.                 else
  724.                     newpiece = TRUE;
  725. }
  726.             else if(board.piecepos== 2)
  727. {
  728.                 if(board.piecey <= 16)
  729. {
  730.                     if( board.square[board.piecex][board.piecey + 2]== 0 && board.square[board.piecex + 1][board.piecey+1]== 0)
  731. {
  732.                         board.square[board.piecex][board.piecey + 2] = 1;
  733.                         board.square[board.piecex+1][board.piecey+1] = 1;
  734.                         board.square[board.piecex][board.piecey -1] = 0;
  735.                         board.square[board.piecex+1][board.piecey] = 0;
  736.                         board.piecey = board.piecey + 1;
  737. }
  738.                     else
  739.                         newpiece = TRUE;
  740. }
  741.                 else
  742.                     newpiece = TRUE;
  743. }
  744.             else if(board.piecepos == 3)
  745. {
  746.                 if(board.piecey <= 16)
  747. {
  748.                     if( board.square[board.piecex-1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey+2]== 0 && board.square[board.piecex+1][board.piecey+1]== 0)
  749. {
  750.                         board.square[board.piecex-1][board.piecey + 1] = 1;
  751.                         board.square[board.piecex][board.piecey+2] = 1;
  752. board.square[board.piecex+1][board.piecey + 1] = 1;
  753.                         board.square[board.piecex-1][board.piecey] = 0;
  754.                         board.square[board.piecex][board.piecey] = 0;
  755. board.square[board.piecex+1][board.piecey] = 0;
  756.                         board.piecey = board.piecey + 1;
  757. }
  758.                     else
  759.                         newpiece = TRUE;
  760. }
  761.                 else
  762.                     newpiece = TRUE;
  763. }
  764.             else if(board.piecepos== 4)
  765.             {
  766.                 if(board.piecey <= 16)
  767. {
  768.                     if( board.square[board.piecex-1][board.piecey+1]== 0 && board.square[board.piecex][board.piecey+2]== 0)
  769. {
  770.                         board.square[board.piecex-1][board.piecey+1] = 1;
  771.                         board.square[board.piecex][board.piecey+2] = 1;
  772.                         board.square[board.piecex][board.piecey -1] = 0;
  773.                         board.square[board.piecex-1][board.piecey] = 0;
  774.                         board.piecey = board.piecey + 1;
  775. }
  776.                     else
  777.                         newpiece = TRUE;
  778. }
  779.                 else
  780.                     newpiece = TRUE;
  781. }
  782. }
  783. break;
  784. case 7:
  785. {
  786.             if(board.piecey <= 17)
  787. {
  788.                     if(board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  789. {
  790.                         board.square[board.piecex][board.piecey + 1]= 1;
  791.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  792.                         board.square[board.piecex][board.piecey-1] = 0;
  793.                         board.square[board.piecex+1][board.piecey-1] = 0;
  794.                         board.piecey = board.piecey + 1;
  795. }
  796.                     else
  797.                         newpiece = TRUE;
  798. }
  799.                 else
  800.                     newpiece = TRUE;
  801. }
  802. break;
  803. }
  804. return;
  805. }
  806. void CRussianGameDlg::movepieceleft()
  807. {
  808. int i,curpiece;
  809. curpiece=board.curpiece; 
  810. switch (curpiece)
  811. {
  812.         case 1:
  813.             if(board.piecepos== 1)
  814. {
  815.                 if(board.piecex >= 3)
  816.                     if(board.square[board.piecex - 2][board.piecey]== 0)
  817. {
  818.                         board.square[board.piecex - 2][board.piecey]= 1;
  819.                         board.square[board.piecex + 2][board.piecey] = 0;
  820.                         board.piecex = board.piecex - 1;
  821.                     }
  822. }
  823.             else if(board.piecepos == 2)
  824. {
  825.                 if(board.piecex >= 2)
  826.                     if(board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0 && board.square[board.piecex - 1][board.piecey + 2] == 0)
  827. {
  828.                         for(i = board.piecey - 1;i<=board.piecey + 2;i++)
  829. {
  830.                             board.square[board.piecex - 1][i] = 1;
  831.                             board.square[board.piecex][i] = 0;
  832.                         }
  833.                         board.piecex = board.piecex - 1;
  834.                     }
  835. }
  836. break;
  837.         case 2:
  838.             if(board.piecepos == 1)
  839. {
  840.                 if(board.piecex >= 3)
  841.                     if(board.square[board.piecex - 2][board.piecey] == 0 && board.square[board.piecex - 2][board.piecey - 1]== 0)
  842. {
  843.                         board.square[board.piecex - 2][board.piecey]=1;
  844.                         board.square[board.piecex - 2][board.piecey-1] = 1;
  845.                         board.square[board.piecex - 1][board.piecey-1] = 0;
  846.                         board.square[board.piecex +1][board.piecey] = 0;
  847.                         board.piecex = board.piecex - 1;
  848.                     }
  849. }
  850.             else if(board.piecepos == 2)
  851. {
  852.                 if(board.piecex >= 2)
  853.                     if(board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0)
  854. {
  855.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  856. {
  857.                             board.square[board.piecex - 1][i] = 1;
  858.                             board.square[board.piecex][i] = 0;
  859.                         }
  860.                         board.square[board.piecex][board.piecey - 1] = 1;
  861.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  862.                         board.piecex = board.piecex - 1;
  863.                     }
  864. }
  865.             else if(board.piecepos== 3)
  866. {
  867.                 if(board.piecex >= 3)
  868.                     if(board.square[board.piecex - 2][board.piecey]== 0 && board.square[board.piecex][board.piecey + 1]== 0)
  869. {
  870.                         board.square[board.piecex - 2][board.piecey] = 1;
  871.                         board.square[board.piecex][board.piecey + 1]= 1;
  872.                         board.square[board.piecex + 1][board.piecey] = 0;
  873.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  874.                         board.piecex = board.piecex - 1;
  875.                     }
  876. }
  877.             else if(board.piecepos == 4)
  878. {
  879.                 if(board.piecex >= 3)
  880.                     if( board.square[board.piecex - 1][board.piecey - 1] == 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 2][board.piecey + 1]== 0)
  881. {
  882.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  883.                         board.square[board.piecex - 1][board.piecey] = 1;
  884.                         board.square[board.piecex - 2][board.piecey + 1] = 1;
  885.                         board.square[board.piecex][board.piecey - 1] = 0;
  886.                         board.square[board.piecex][board.piecey] = 0;
  887.                         board.square[board.piecex][board.piecey + 1] = 0;
  888.                         board.piecex = board.piecex - 1;
  889.                     }
  890. }
  891. break;
  892.         case 3:
  893. if(board.piecepos == 1)
  894. {
  895.                 if(board.piecex >= 3)
  896.                     if(board.square[board.piecex - 2][board.piecey] == 0 && board.square[board.piecex][board.piecey - 1]== 0)
  897. {
  898.                         board.square[board.piecex - 2][board.piecey]=1;
  899.                         board.square[board.piecex][board.piecey-1] = 1;
  900.                         board.square[board.piecex +1][board.piecey-1] = 0;
  901.                         board.square[board.piecex +1][board.piecey] = 0;
  902.                         board.piecex = board.piecex - 1;
  903.                     }
  904. }
  905.             else if(board.piecepos == 2)
  906. {
  907.                 if(board.piecex >= 2)
  908.                     if(board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0)
  909. {
  910.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  911. {
  912.                             board.square[board.piecex - 1][i] = 1;
  913.                             board.square[board.piecex][i] = 0;
  914.                         }
  915.                         board.square[board.piecex][board.piecey +1] = 1;
  916.                         board.square[board.piecex + 1][board.piecey +1] = 0;
  917.                         board.piecex = board.piecex - 1;
  918.                     }
  919. }
  920.             else if(board.piecepos== 3)
  921. {
  922.                 if(board.piecex >= 3)
  923.                     if(board.square[board.piecex - 2][board.piecey]== 0 && board.square[board.piecex-2][board.piecey + 1] == 0)
  924. {
  925.                         board.square[board.piecex - 2][board.piecey] = 1;
  926.                         board.square[board.piecex-2][board.piecey + 1]= 1;
  927.                         board.square[board.piecex + 1][board.piecey] = 0;
  928.                         board.square[board.piecex - 1][board.piecey + 1] = 0;
  929.                         board.piecex = board.piecex - 1;
  930.                     }
  931. }
  932.             else if(board.piecepos == 4)
  933. {
  934.                 if(board.piecex >= 3)
  935.                     if( board.square[board.piecex - 2][board.piecey - 1] == 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0)
  936. {
  937.                         board.square[board.piecex - 2][board.piecey - 1] = 1;
  938.                         board.square[board.piecex - 1][board.piecey] = 1;
  939.                         board.square[board.piecex - 1][board.piecey + 1] = 1;
  940.                         board.square[board.piecex][board.piecey - 1] = 0;
  941.                         board.square[board.piecex][board.piecey] = 0;
  942.                         board.square[board.piecex][board.piecey + 1] = 0;
  943.                         board.piecex = board.piecex - 1;
  944.                     }
  945. }
  946. break;
  947.         case 4:
  948.             if(board.piecepos == 1)
  949. {
  950.                 if(board.piecex >= 3)
  951.                     if(board.square[board.piecex - 2][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0)
  952. {
  953.                         board.square[board.piecex - 2][board.piecey - 1] = 1;
  954.                         board.square[board.piecex - 1][board.piecey] = 1;
  955.                         board.square[board.piecex][board.piecey - 1] = 0;
  956.                         board.square[board.piecex + 1][board.piecey] = 0;
  957.                         board.piecex = board.piecex - 1;
  958.                     }
  959. }
  960.             else if(board.piecepos == 2)
  961. {
  962.                 if(board.piecex >= 2)
  963.                     if(board.square[board.piecex - 1][board.piecey] == 0 && board.square[board.piecex - 1][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey - 1] == 0)
  964. {
  965.                         board.square[board.piecex - 1][board.piecey] = 1;
  966.                         board.square[board.piecex - 1][board.piecey + 1] = 1;
  967.                         board.square[board.piecex][board.piecey - 1] = 1;
  968.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  969.                         board.square[board.piecex + 1][board.piecey] = 0;
  970.                         board.square[board.piecex][board.piecey + 1] = 0;
  971.                         board.piecex = board.piecex - 1;
  972. }
  973. }
  974. break;
  975.         case 5:
  976. if(board.piecepos == 1)
  977. {
  978.                 if(board.piecex >= 3)
  979.                     if(board.square[board.piecex - 2][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey-1]== 0)
  980. {
  981.                         board.square[board.piecex - 2][board.piecey] = 1;
  982.                         board.square[board.piecex - 1][board.piecey-1] = 1;
  983.                         board.square[board.piecex][board.piecey] = 0;
  984.                         board.square[board.piecex + 1][board.piecey-1] = 0;
  985.                         board.piecex = board.piecex - 1;
  986.                     }
  987. }
  988.             else if(board.piecepos == 2)
  989. {
  990.                 if(board.piecex >= 2)
  991.                     if(board.square[board.piecex - 1][board.piecey] == 0 && board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex][board.piecey + 1] == 0)
  992. {
  993.                         board.square[board.piecex - 1][board.piecey] = 1;
  994.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  995.                         board.square[board.piecex][board.piecey + 1] = 1;
  996.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  997.                         board.square[board.piecex + 1][board.piecey] = 0;
  998.                         board.square[board.piecex][board.piecey - 1] = 0;
  999.                         board.piecex = board.piecex - 1;
  1000. }
  1001. }
  1002. break;
  1003.         case 6:
  1004. if(board.piecepos == 1)
  1005. {
  1006.                 if(board.piecex >= 3)
  1007.                     if(board.square[board.piecex - 2][board.piecey] == 0 && board.square[board.piecex - 1][board.piecey - 1]== 0)
  1008. {
  1009.                         board.square[board.piecex - 2][board.piecey]=1;
  1010.                         board.square[board.piecex - 1][board.piecey-1] = 1;
  1011.                         board.square[board.piecex][board.piecey-1] = 0;
  1012.                         board.square[board.piecex +1][board.piecey] = 0;
  1013.                         board.piecex = board.piecex - 1;
  1014.                     }
  1015. }
  1016.             else if(board.piecepos == 2)
  1017. {
  1018.                 if(board.piecex >= 2)
  1019.                     if(board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0)
  1020. {
  1021.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  1022. {
  1023.                             board.square[board.piecex - 1][i] = 1;
  1024.                             board.square[board.piecex][i] = 0;
  1025.                         }
  1026.                         board.square[board.piecex][board.piecey] = 1;
  1027.                         board.square[board.piecex + 1][board.piecey] = 0;
  1028.                         board.piecex = board.piecex - 1;
  1029.                     }
  1030. }
  1031.             else if(board.piecepos== 3)
  1032. {
  1033.                 if(board.piecex >= 3)
  1034.                     if(board.square[board.piecex - 2][board.piecey]== 0 && board.square[board.piecex-1][board.piecey + 1]== 0)
  1035. {
  1036.                         board.square[board.piecex - 2][board.piecey] = 1;
  1037.                         board.square[board.piecex-1][board.piecey + 1]= 1;
  1038.                         board.square[board.piecex + 1][board.piecey] = 0;
  1039.                         board.square[board.piecex][board.piecey + 1] = 0;
  1040.                         board.piecex = board.piecex - 1;
  1041.                     }
  1042. }
  1043.             else if(board.piecepos == 4)
  1044. {
  1045.                 if(board.piecex >= 3)
  1046.                     if( board.square[board.piecex - 1][board.piecey - 1] == 0 && board.square[board.piecex - 2][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1]== 0)
  1047. {
  1048.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  1049.                         board.square[board.piecex - 2][board.piecey] = 1;
  1050.                         board.square[board.piecex - 1][board.piecey + 1] = 1;
  1051.                         board.square[board.piecex][board.piecey - 1] = 0;
  1052.                         board.square[board.piecex][board.piecey] = 0;
  1053.                         board.square[board.piecex][board.piecey + 1] = 0;
  1054.                         board.piecex = board.piecex - 1;
  1055.                     }
  1056. }
  1057. break;
  1058.         case 7:
  1059.            if(board.piecex >= 2)
  1060.    {
  1061.                 if( board.square[board.piecex - 1][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey]== 0)
  1062. {
  1063.                     board.square[board.piecex - 1][board.piecey - 1] = 1;
  1064.                     board.square[board.piecex - 1][board.piecey] = 1;
  1065.                     board.square[board.piecex + 1][board.piecey - 1] = 0;
  1066.                     board.square[board.piecex + 1][board.piecey] = 0;
  1067.                     board.piecex = board.piecex - 1;
  1068.                 }
  1069. }
  1070. break;
  1071. }
  1072. InvalidateRect(&rect,FALSE);
  1073. return;
  1074. }
  1075. void CRussianGameDlg::movepieceright()
  1076. {
  1077. int i,curpiece;
  1078. curpiece=board.curpiece; 
  1079. switch (curpiece)
  1080. {
  1081.         case 1:
  1082.             if(board.piecepos== 1)
  1083. {
  1084.                 if(board.piecex <= 7)
  1085.                     if(board.square[board.piecex +3][board.piecey]== 0)
  1086. {
  1087.                         board.square[board.piecex +3][board.piecey]= 1;
  1088.                         board.square[board.piecex -1][board.piecey] = 0;
  1089.                         board.piecex = board.piecex + 1;
  1090.                     }
  1091. }
  1092.             else if(board.piecepos == 2)
  1093. {
  1094.                 if(board.piecex <= 9)
  1095.                     if(board.square[board.piecex + 1][board.piecey - 1]== 0 && board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0 && board.square[board.piecex + 1][board.piecey + 2] == 0)
  1096. {
  1097.                         for(i = board.piecey - 1;i<=board.piecey + 2;i++)
  1098. {
  1099.                             board.square[board.piecex + 1][i] = 1;
  1100.                             board.square[board.piecex][i] = 0;
  1101.                         }
  1102.                         board.piecex = board.piecex + 1;
  1103.                     }
  1104. }
  1105. break;
  1106.         case 2:
  1107.             if(board.piecepos == 1)
  1108. {
  1109.                 if(board.piecex <= 8)
  1110.                     if(board.square[board.piecex + 2][board.piecey] == 0 && board.square[board.piecex ][board.piecey - 1]== 0)
  1111. {
  1112.                         board.square[board.piecex + 2][board.piecey]=1;
  1113.                         board.square[board.piecex ][board.piecey-1] = 1;
  1114.                         board.square[board.piecex - 1][board.piecey] = 0;
  1115.                         board.square[board.piecex -1][board.piecey-1] = 0;
  1116.                         board.piecex = board.piecex + 1;
  1117.                     }
  1118. }
  1119.             else if(board.piecepos == 2)
  1120. {
  1121.                 if(board.piecex <= 8)
  1122.                     if(board.square[board.piecex +2][board.piecey - 1]== 0 && board.square[board.piecex +1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0)
  1123. {
  1124.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  1125. {
  1126.                             board.square[board.piecex + 1][i] = 1;
  1127.                             board.square[board.piecex][i] = 0;
  1128.                         }
  1129.                         board.square[board.piecex+2][board.piecey - 1] = 1;
  1130.                         board.piecex = board.piecex + 1;
  1131.                     }
  1132. }
  1133.             else if(board.piecepos== 3)
  1134. {
  1135.                 if(board.piecex <= 8)
  1136.                     if(board.square[board.piecex + 2][board.piecey]== 0 && board.square[board.piecex+2][board.piecey + 1]== 0)
  1137. {
  1138.                         board.square[board.piecex + 2][board.piecey] = 1;
  1139.                         board.square[board.piecex+2][board.piecey + 1]= 1;
  1140.                         board.square[board.piecex - 1][board.piecey] = 0;
  1141.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  1142.                         board.piecex = board.piecex + 1;
  1143.                     }
  1144. }
  1145.             else if(board.piecepos == 4)
  1146. {
  1147.                 if(board.piecex <= 9)
  1148.                     if( board.square[board.piecex + 1][board.piecey - 1] == 0 && board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex +1][board.piecey + 1]== 0)
  1149. {
  1150.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1151.                         board.square[board.piecex + 1][board.piecey] = 1;
  1152.                         board.square[board.piecex +1][board.piecey + 1] = 1;
  1153.                         board.square[board.piecex][board.piecey - 1] = 0;
  1154.                         board.square[board.piecex][board.piecey] = 0;
  1155.                         board.square[board.piecex-1][board.piecey + 1] = 0;
  1156.                         board.piecex = board.piecex + 1;
  1157.                     }
  1158. }
  1159. break;
  1160.         case 3:
  1161. if(board.piecepos == 1)
  1162. {
  1163.                 if(board.piecex <= 8)
  1164.                     if(board.square[board.piecex + 2][board.piecey] == 0 && board.square[board.piecex+2][board.piecey - 1]== 0)
  1165. {
  1166.                         board.square[board.piecex + 2][board.piecey]=1;
  1167.                         board.square[board.piecex+2][board.piecey-1] = 1;
  1168.                         board.square[board.piecex -1][board.piecey] = 0;
  1169.                         board.square[board.piecex +1][board.piecey-1] = 0;
  1170.                         board.piecex = board.piecex + 1;
  1171.                     }
  1172. }
  1173.             else if(board.piecepos == 2)
  1174. {
  1175.                 if(board.piecex <= 8)
  1176.                     if(board.square[board.piecex +2][board.piecey + 1]== 0 && board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey - 1]== 0)
  1177. {
  1178.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  1179. {
  1180.                             board.square[board.piecex + 1][i] = 1;
  1181.                             board.square[board.piecex][i] = 0;
  1182.                         }
  1183.                         board.square[board.piecex+2][board.piecey +1] = 1;
  1184.                         board.piecex = board.piecex + 1;
  1185.                     }
  1186. }
  1187.             else if(board.piecepos== 3)
  1188. {
  1189.                 if(board.piecex <= 8)
  1190.                     if(board.square[board.piecex + 2][board.piecey]== 0 && board.square[board.piecex][board.piecey + 1] == 0)
  1191. {
  1192.                         board.square[board.piecex + 2][board.piecey] = 1;
  1193.                         board.square[board.piecex][board.piecey + 1]= 1;
  1194.                         board.square[board.piecex - 1][board.piecey] = 0;
  1195.                         board.square[board.piecex - 1][board.piecey + 1] = 0;
  1196.                         board.piecex = board.piecex + 1;
  1197.                     }
  1198. }
  1199.             else if(board.piecepos == 4)
  1200. {
  1201.                 if(board.piecex <= 9)
  1202.                     if( board.square[board.piecex +1][board.piecey - 1] == 0 && board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0)
  1203. {
  1204.                         board.square[board.piecex+ 1][board.piecey - 1] = 1;
  1205.                         board.square[board.piecex + 1][board.piecey] = 1;
  1206.                         board.square[board.piecex + 1][board.piecey + 1] = 1;
  1207.                         board.square[board.piecex][board.piecey + 1] = 0;
  1208.                         board.square[board.piecex][board.piecey] = 0;
  1209.                         board.square[board.piecex-1][board.piecey - 1] = 0;
  1210.                         board.piecex = board.piecex + 1;
  1211.                     }
  1212. }
  1213. break;
  1214.         case 4:
  1215.             if(board.piecepos == 1)
  1216. {
  1217.                 if(board.piecex <= 8)
  1218.                     if(board.square[board.piecex + 2][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey-1]== 0)
  1219. {
  1220.                         board.square[board.piecex + 2][board.piecey] = 1;
  1221.                         board.square[board.piecex + 1][board.piecey-1] = 1;
  1222.                         board.square[board.piecex][board.piecey] = 0;
  1223.                         board.square[board.piecex - 1][board.piecey-1] = 0;
  1224.                         board.piecex = board.piecex + 1;
  1225.                     }
  1226. }
  1227.             else if(board.piecepos == 2)
  1228. {
  1229.                 if(board.piecex <= 8)
  1230.                     if(board.square[board.piecex +2][board.piecey] == 0 && board.square[board.piecex +2][board.piecey - 1]== 0 && board.square[board.piecex+1][board.piecey + 1] == 0)
  1231. {
  1232.                         board.square[board.piecex +2][board.piecey] = 1;
  1233.                         board.square[board.piecex + 2][board.piecey - 1] = 1;
  1234.                         board.square[board.piecex+1][board.piecey + 1] = 1;
  1235.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  1236.                         board.square[board.piecex ][board.piecey+1] = 0;
  1237.                         board.square[board.piecex][board.piecey] = 0;
  1238.                         board.piecex = board.piecex + 1;
  1239. }
  1240. }
  1241. break;
  1242.         case 5:
  1243. if(board.piecepos == 1)
  1244. {
  1245.                 if(board.piecex <= 8)
  1246.                     if(board.square[board.piecex + 2][board.piecey-1]== 0 && board.square[board.piecex + 1][board.piecey]== 0)
  1247. {
  1248.                         board.square[board.piecex + 2][board.piecey-1] = 1;
  1249.                         board.square[board.piecex + 1][board.piecey] = 1;
  1250.                         board.square[board.piecex-1][board.piecey] = 0;
  1251.                         board.square[board.piecex ][board.piecey-1] = 0;
  1252.                         board.piecex = board.piecex + 1;
  1253.                     }
  1254. }
  1255.             else if(board.piecepos == 2)
  1256. {
  1257.                 if(board.piecex <= 8)
  1258.                     if(board.square[board.piecex + 2][board.piecey] == 0 && board.square[board.piecex +2][board.piecey + 1]== 0 && board.square[board.piecex+1][board.piecey - 1] == 0)
  1259. {
  1260.                         board.square[board.piecex +2][board.piecey] = 1;
  1261.                         board.square[board.piecex +2][board.piecey +1] = 1;
  1262.                         board.square[board.piecex+1][board.piecey - 1] = 1;
  1263.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  1264.                         board.square[board.piecex][board.piecey-1] = 0;
  1265.                         board.square[board.piecex][board.piecey] = 0;
  1266.                         board.piecex = board.piecex + 1;
  1267. }
  1268. }
  1269. break;
  1270.         case 6:
  1271. if(board.piecepos == 1)
  1272. {
  1273.                 if(board.piecex <= 8)
  1274.                     if(board.square[board.piecex + 2][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey - 1]== 0)
  1275. {
  1276.                         board.square[board.piecex + 2][board.piecey]=1;
  1277.                         board.square[board.piecex + 1][board.piecey-1] = 1;
  1278.                         board.square[board.piecex][board.piecey-1] = 0;
  1279.                         board.square[board.piecex -1][board.piecey] = 0;
  1280.                         board.piecex = board.piecex + 1;
  1281.                     }
  1282. }
  1283.             else if(board.piecepos == 2)
  1284. {
  1285.                 if(board.piecex <= 8)
  1286.                     if(board.square[board.piecex + 1][board.piecey - 1]== 0 && board.square[board.piecex +2][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0)
  1287. {
  1288.                         for(i = board.piecey - 1;i<=board.piecey + 1;i++)
  1289. {
  1290.                             board.square[board.piecex + 1][i] = 1;
  1291.                             board.square[board.piecex][i] = 0;
  1292.                         }
  1293.                         board.square[board.piecex+2][board.piecey] = 1;
  1294.                         board.piecex = board.piecex + 1;
  1295.                     }
  1296. }
  1297.             else if(board.piecepos== 3)
  1298. {
  1299.                 if(board.piecex <= 8)
  1300.                     if(board.square[board.piecex + 2][board.piecey]== 0 && board.square[board.piecex+1][board.piecey + 1]== 0)
  1301. {
  1302.                         board.square[board.piecex + 2][board.piecey] = 1;
  1303.                         board.square[board.piecex+1][board.piecey + 1]= 1;
  1304.                         board.square[board.piecex - 1][board.piecey] = 0;
  1305.                         board.square[board.piecex][board.piecey + 1] = 0;
  1306.                         board.piecex = board.piecex + 1;
  1307.                     }
  1308. }
  1309.             else if(board.piecepos == 4)
  1310. {
  1311.                 if(board.piecex <= 9)
  1312.                     if( board.square[board.piecex + 1][board.piecey - 1] == 0 && board.square[board.piecex +1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey + 1]== 0)
  1313. {
  1314.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1315.                         board.square[board.piecex +1][board.piecey] = 1;
  1316.                         board.square[board.piecex + 1][board.piecey + 1] = 1;
  1317.                         board.square[board.piecex][board.piecey - 1] = 0;
  1318.                         board.square[board.piecex-1][board.piecey] = 0;
  1319.                         board.square[board.piecex][board.piecey + 1] = 0;
  1320.                         board.piecex = board.piecex + 1;
  1321.                     }
  1322. }
  1323. break;
  1324.         case 7:
  1325.             if(board.piecex <= 8)
  1326.                 if( board.square[board.piecex +2][board.piecey - 1]== 0 && board.square[board.piecex +2][board.piecey]== 0)
  1327. {
  1328.                     board.square[board.piecex +2][board.piecey - 1] = 1;
  1329.                     board.square[board.piecex +2][board.piecey] = 1;
  1330.                     board.square[board.piecex ][board.piecey - 1] = 0;
  1331.                     board.square[board.piecex ][board.piecey] = 0;
  1332.                     board.piecex = board.piecex + 1;
  1333.                 }
  1334. break;
  1335. }
  1336. InvalidateRect(&rect,FALSE);
  1337. return;
  1338. }
  1339. void CRussianGameDlg::roatepiece()
  1340. {
  1341. int curpiece;
  1342. curpiece=board.curpiece;
  1343. switch (curpiece)
  1344. {
  1345. case 1:
  1346.             if(board.piecepos== 1)
  1347. {
  1348. if(board.piecey > 1 && board.piecey <= 16)
  1349.                     if (board.square[board.piecex][board.piecey - 1]== 0 && board.square[board.piecex][board.piecey + 1]== 0 && board.square[board.piecex][board.piecey + 2]== 0)
  1350. {
  1351.                         board.square[board.piecex - 1][board.piecey] = 0;
  1352.                         board.square[board.piecex + 1][board.piecey] = 0;
  1353.                         board.square[board.piecex + 2][board.piecey] = 0;
  1354.                         board.square[board.piecex][board.piecey - 1] = 1;
  1355.                         board.square[board.piecex][board.piecey + 1] = 1;
  1356.                         board.square[board.piecex][board.piecey + 2] = 1;
  1357.                         board.piecepos = 2;
  1358.                     }
  1359. }
  1360.             else if(board.piecepos ==2)
  1361. {
  1362.                 if (board.piecex > 1 && board.piecex <= 8 )
  1363.                     if(board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey] == 0 && board.square[board.piecex + 2][board.piecey]== 0)
  1364. {
  1365.                         board.square[board.piecex - 1][board.piecey] = 1;
  1366.                         board.square[board.piecex + 1][board.piecey] = 1;
  1367.                         board.square[board.piecex + 2][board.piecey] = 1;
  1368.                         board.square[board.piecex][board.piecey - 1] = 0;
  1369.                         board.square[board.piecex][board.piecey + 1] = 0;
  1370.                         board.square[board.piecex][board.piecey + 2] = 0;
  1371.                         board.piecepos = 1;
  1372.                     }
  1373. }
  1374. break;
  1375. case 2:
  1376.             if(board.piecepos == 1)
  1377. {
  1378.                 if(board.piecey <= 17)
  1379.                     if (board.square[board.piecex][board.piecey - 1] == 0 && board.square[board.piecex + 1][board.piecey - 1] == 0 && board.square[board.piecex][board.piecey + 1]== 0)
  1380. {
  1381.                         board.square[board.piecex][board.piecey - 1] = 1;
  1382.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1383.                         board.square[board.piecex][board.piecey + 1] = 1;
  1384.                         board.square[board.piecex - 1][board.piecey] = 0;
  1385.                         board.square[board.piecex - 1][board.piecey - 1] = 0;
  1386.                         board.square[board.piecex + 1][board.piecey] = 0;
  1387.                         board.piecepos = 2;
  1388.                     }
  1389. }
  1390.             else if(board.piecepos == 2)
  1391. {
  1392.                 if(board.piecex > 1)
  1393.                     if(board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex + 1][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey + 1]== 0)
  1394. {
  1395.                         board.square[board.piecex - 1][board.piecey] = 1;
  1396.                         board.square[board.piecex + 1][board.piecey] = 1;
  1397.                         board.square[board.piecex + 1][board.piecey + 1] = 1;
  1398.                         board.square[board.piecex][board.piecey - 1] = 0;
  1399.                         board.square[board.piecex][board.piecey + 1] = 0;
  1400.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  1401.                         board.piecepos = 3;
  1402.                     }
  1403. }
  1404.             else if(board.piecepos == 3)
  1405. {
  1406.                 if(board.piecey > 1)
  1407.                     if(board.square[board.piecex][board.piecey - 1] == 0 && board.square[board.piecex][board.piecey + 1] == 0 && board.square[board.piecex - 1][board.piecey + 1] == 0)
  1408. {
  1409.                         board.square[board.piecex][board.piecey - 1] = 1;
  1410.                         board.square[board.piecex][board.piecey + 1] = 1;
  1411.                         board.square[board.piecex - 1][board.piecey + 1] = 1;
  1412.                         board.square[board.piecex - 1][board.piecey] = 0;
  1413.                         board.square[board.piecex + 1][board.piecey] = 0;
  1414.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  1415.                         board.piecepos = 4;
  1416.                     }
  1417. }
  1418.             else if(board.piecepos == 4)
  1419. {
  1420.                 if(board.piecex < 10)
  1421.                     if(board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey - 1] == 0)
  1422. {
  1423.                         board.square[board.piecex + 1][board.piecey] = 1;
  1424.                         board.square[board.piecex - 1][board.piecey] = 1;
  1425.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  1426.                         board.square[board.piecex][board.piecey - 1] = 0;
  1427.                         board.square[board.piecex][board.piecey + 1] = 0;
  1428.                         board.square[board.piecex - 1][board.piecey + 1] = 0;
  1429.                         board.piecepos = 1;
  1430.                     }
  1431. }
  1432. break;
  1433. case 3:
  1434.             if(board.piecepos == 1)
  1435. {
  1436.                 if(board.piecey <=17)
  1437.                     if(board.square[board.piecex][board.piecey - 1]== 0 && board.square[board.piecex + 1][board.piecey + 1] == 0 && board.square[board.piecex][board.piecey + 1] == 0)
  1438. {
  1439.                         board.square[board.piecex][board.piecey - 1] = 1;
  1440.                         board.square[board.piecex + 1][board.piecey + 1] = 1;
  1441.                         board.square[board.piecex][board.piecey + 1] = 1;
  1442.                         board.square[board.piecex - 1][board.piecey] = 0;
  1443.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  1444.                         board.square[board.piecex + 1][board.piecey] = 0;
  1445.                         board.piecepos = 2;
  1446.                     }
  1447. }
  1448.             else if(board.piecepos==2)
  1449. {
  1450.                 if(board.piecex > 1)
  1451.                     if(board.square[board.piecex - 1][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey]== 0 && board.square[board.piecex - 1][board.piecey + 1] == 0)
  1452. {
  1453.                         board.square[board.piecex - 1][board.piecey] = 1;
  1454.                         board.square[board.piecex + 1][board.piecey] = 1;
  1455.                         board.square[board.piecex - 1][board.piecey + 1] = 1;
  1456.                         board.square[board.piecex][board.piecey - 1] = 0;
  1457.                         board.square[board.piecex][board.piecey + 1] = 0;
  1458.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  1459.                         board.piecepos = 3;
  1460.                     }
  1461. }
  1462.             else if(board.piecepos == 3)
  1463. {
  1464.                 if(board.piecey > 1)
  1465.                     if(board.square[board.piecex][board.piecey - 1]== 0 && board.square[board.piecex][board.piecey + 1] == 0 && board.square[board.piecex - 1][board.piecey - 1] ==0)
  1466. {
  1467.                         board.square[board.piecex][board.piecey - 1] = 1;
  1468.                         board.square[board.piecex][board.piecey + 1] = 1;
  1469.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  1470.                         board.square[board.piecex - 1][board.piecey] = 0;
  1471.                         board.square[board.piecex + 1][board.piecey] = 0;
  1472.                         board.square[board.piecex - 1][board.piecey + 1] = 0;
  1473.                         board.piecepos = 4;
  1474. }
  1475. }
  1476.             else if(board.piecepos == 4)
  1477. {
  1478.                 if(board.piecex < 10)
  1479.                     if(board.square[board.piecex + 1][board.piecey] == 0 && board.square[board.piecex - 1][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey - 1] ==0)
  1480. {
  1481.                         board.square[board.piecex + 1][board.piecey] = 1;
  1482.                         board.square[board.piecex - 1][board.piecey] = 1;
  1483.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1484.                         board.square[board.piecex][board.piecey - 1] = 0;
  1485.                         board.square[board.piecex][board.piecey + 1] = 0;
  1486.                         board.square[board.piecex - 1][board.piecey - 1] = 0;
  1487.                         board.piecepos = 1;
  1488.                     }
  1489. }
  1490. break;
  1491. case 4:
  1492.             if(board.piecepos == 1)
  1493. {
  1494.                 if(board.piecey < 18)
  1495.                     if(board.square[board.piecex + 1][board.piecey - 1]== 0 && board.square[board.piecex][board.piecey + 1] == 0 )
  1496. {
  1497.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1498.                         board.square[board.piecex][board.piecey + 1] = 1;
  1499.                         board.square[board.piecex][board.piecey - 1] = 0;
  1500.                         board.square[board.piecex - 1][board.piecey - 1] = 0;
  1501.                         board.piecepos = 2;
  1502.                     }
  1503. }
  1504.             else if(board.piecepos == 2)
  1505. {
  1506.                 if(board.piecex > 1)
  1507.                     if(board.square[board.piecex][board.piecey - 1]== 0 && board.square[board.piecex - 1][board.piecey - 1] == 0 )
  1508. {
  1509.                         board.square[board.piecex][board.piecey - 1] = 1;
  1510.                         board.square[board.piecex - 1][board.piecey - 1] = 1;
  1511.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  1512.                         board.square[board.piecex][board.piecey + 1] = 0;
  1513.                         board.piecepos = 1;
  1514. }
  1515. }
  1516. break;
  1517. case 5:
  1518.             if(board.piecepos == 1)
  1519. {
  1520.                 if(board.piecey < 18 )
  1521.                     if(board.square[board.piecex + 1][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey + 1] == 0 )
  1522. {
  1523.                         board.square[board.piecex + 1][board.piecey] = 1;
  1524.                         board.square[board.piecex + 1][board.piecey + 1] = 1;
  1525.                         board.square[board.piecex - 1][board.piecey] = 0;
  1526.                         board.square[board.piecex + 1][board.piecey - 1] = 0;
  1527.                         board.piecepos = 2;
  1528.                     }
  1529. }
  1530.             else if(board.piecepos == 2)
  1531. {
  1532.                 if(board.piecex > 1 )
  1533.                     if(board.square[board.piecex - 1][board.piecey] == 0 && board.square[board.piecex + 1][board.piecey - 1] == 0)
  1534. {
  1535.                         board.square[board.piecex - 1][board.piecey] = 1;
  1536.                         board.square[board.piecex + 1][board.piecey - 1] = 1;
  1537.                         board.square[board.piecex + 1][board.piecey] = 0;
  1538.                         board.square[board.piecex + 1][board.piecey + 1] = 0;
  1539.                         board.piecepos = 1;
  1540.                     }
  1541. }
  1542. break;
  1543. case 6:
  1544.            if(board.piecepos == 1)
  1545.    {
  1546.                 if(board.piecey <= 17)
  1547.                     if(board.square[board.piecex][board.piecey + 1] == 0 )
  1548. {
  1549.                         board.square[board.piecex][board.piecey + 1] = 1;
  1550.                         board.square[board.piecex - 1][board.piecey] = 0;
  1551.                         board.piecepos = 2;
  1552.                     }
  1553.    }
  1554.             else if(board.piecepos == 2)
  1555. {
  1556.                 if(board.piecex > 1)
  1557.                     if(board.square[board.piecex - 1][board.piecey] == 0)
  1558. {
  1559.                         board.square[board.piecex - 1][board.piecey] = 1;
  1560.                         board.square[board.piecex][board.piecey - 1] = 0;
  1561.                         board.piecepos = 3;
  1562. }
  1563. }
  1564.             else if(board.piecepos == 3)
  1565. {
  1566.                 if(board.piecey > 1)
  1567.                     if(board.square[board.piecex][board.piecey - 1] == 0)
  1568. {
  1569.                         board.square[board.piecex][board.piecey - 1] = 1;
  1570.                         board.square[board.piecex + 1][board.piecey] = 0;
  1571.                         board.piecepos = 4;
  1572.                     }
  1573. }
  1574.             else if(board.piecepos == 4)
  1575. {
  1576.                 if(board.piecex < 10)
  1577.                     if(board.square[board.piecex + 1][board.piecey] == 0)
  1578. {
  1579.                         board.square[board.piecex + 1][board.piecey] = 1;
  1580.                         board.square[board.piecex][board.piecey + 1] = 0;
  1581.                         board.piecepos = 1;
  1582.                     }
  1583. }
  1584. break;
  1585. }
  1586. InvalidateRect(&rect,FALSE);
  1587. return;
  1588. }
  1589. void CRussianGameDlg::OnSpadd() 
  1590. {
  1591. m_iSp++;
  1592. if(m_iSp==10)m_iSp=1;
  1593. board.level =m_iSp;
  1594. Sp_num.SetNumber(m_iSp);
  1595. // TODO: Add your control notification handler code here
  1596. }
  1597. void CRussianGameDlg::paintpic(CDC *dc)
  1598. {
  1599. int i,j;
  1600. CDC memdc0,memdc1;
  1601. //CDC *pDC=GetDC();
  1602. memdc0.CreateCompatibleDC(dc);
  1603. memdc1.CreateCompatibleDC(dc);
  1604. memdc0.SelectObject(board.pic[0]);
  1605. memdc1.SelectObject(board.pic[1]); 
  1606. for(i = 1;i<=10;i++)
  1607.     for(j = 1;j<=18;j++)
  1608. dc->BitBlt((i-1)*20+1+LeftMargin,(j-1)*20+1+TopMargin,20,20,board.square[i][j]==0?&memdc0:&memdc1,1,1,SRCCOPY); 
  1609. ReleaseDC(dc);
  1610. return;
  1611. }
  1612. void CRussianGameDlg::OnExit() 
  1613. {
  1614. //PostQuitMessage(0);
  1615. KillTimer(1);
  1616. CDialog::EndDialog(0);
  1617. // TODO: Add your control notification handler code here
  1618. }
  1619. void CRussianGameDlg::OnStart() 
  1620. {
  1621. if(pause==FALSE)
  1622. {
  1623. int i,j;
  1624. for(i=0;i<11;i++)
  1625. for(j=0;j<19;j++)
  1626. board.square[i][j]=0; 
  1627. board.level =m_iSp;
  1628. board.scroe =0;
  1629. board.rows =(board.level -1)*10;
  1630. board.game =TRUE;
  1631. board.nextpiece =Random(8);
  1632. if(board.nextpiece ==0)board.nextpiece =5;
  1633. gameover=FALSE;
  1634. newpiece=TRUE;
  1635. if(m_iLine>0)
  1636. {
  1637. int snum;
  1638. for(i = 18;i>=18 - m_iLine + 1;i--)
  1639. {
  1640. srand(i);
  1641. for(j = 1;j<11;j++)
  1642. {
  1643. snum = rand()%5;
  1644. if(snum== 2 )board.square[j][i] = 1;
  1645. }
  1646. }
  1647. }
  1648. }
  1649. else
  1650. pause=FALSE;
  1651. SetTimer(1,1000-m_iSp*105,NULL);
  1652. // TODO: Add your control notification handler code here
  1653. }
  1654. void CRussianGameDlg::OnTimer(UINT nIDEvent) 
  1655. {
  1656. // TODO: Add your message handler code here and/or call default
  1657. if(newpiece==TRUE)
  1658. {
  1659. board.curpiece =board.nextpiece ;
  1660. board.nextpiece =Random(8);
  1661. if(board.nextpiece ==0)board.nextpiece=3;
  1662. PaintNextPic();
  1663. if(board.curpiece ==1)
  1664. board.piecey =1;
  1665. else
  1666. board.piecey =2;
  1667. board.piecex =5;
  1668. board.piecepos =1;
  1669. drawpiece();
  1670. newpiece=FALSE;
  1671. }
  1672. else
  1673. movepiecedown();
  1674. InvalidateRect(&rect,FALSE);
  1675. if(newpiece==TRUE)
  1676. {
  1677. checkforrows();
  1678. }
  1679. if(gameover==TRUE)
  1680. {
  1681. KillTimer(1);
  1682. pause=FALSE;
  1683. board.game =FALSE;
  1684. checkforhighscore();
  1685. MessageBox("游戏已结束,请重新开始!","俄罗斯方块游戏",MB_OK | MB_ICONINFORMATION);
  1686. }
  1687. CDialog::OnTimer(nIDEvent);
  1688. }
  1689. void CRussianGameDlg::checkforrows()
  1690. {
  1691. int i,j,rcount,k;
  1692. rcount=0;
  1693. bool r,row[19], goback;
  1694. goback=TRUE;
  1695.     for(i= 18;i>0;i--)
  1696. {
  1697.         r = TRUE;
  1698.         for(j = 1;j<11;j++)
  1699. {
  1700.             if(board.square[j][i] == 0)
  1701. {
  1702.                 r = FALSE;
  1703.                 break;
  1704. }
  1705.         }
  1706.         row[i] = r;
  1707.         if(r == TRUE)
  1708. {
  1709.             for(j = 1;j<11;j++)
  1710.                 board.square[j][i] = 0;
  1711.             rcount = rcount + 1;
  1712.         }
  1713.     }
  1714.     if (FlagSound == TRUE && rcount>0) PlaySounds();
  1715.     for(i = 18;i>1;i--)
  1716. {
  1717.         if(goback == TRUE)
  1718. {
  1719.             i = i + 1;
  1720.             goback = FALSE;
  1721. }
  1722.         if(row[i] == TRUE)
  1723. {
  1724.             for(k = i;k>1;k--)
  1725. {
  1726.                 for(j = 1;j<11;j++)
  1727.                     board.square[j][k] = board.square[j][k - 1];
  1728.                 row[k] = row[k - 1];
  1729. }
  1730.             goback = TRUE;
  1731. }
  1732.     }
  1733.     InvalidateRect(&rect,FALSE);
  1734.     board.scroe = board.scroe + rcount * 100;
  1735.     board.rows = board.rows + rcount;
  1736.     board.level = board.rows/10 + 1;
  1737. SetTimer(1,1000-board.level*105,NULL); 
  1738. return;
  1739. }
  1740. void CRussianGameDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  1741. {
  1742. // TODO: Add your message handler code here and/or call default
  1743. if(board.game ==TRUE)
  1744. {
  1745. switch(nChar)
  1746. {
  1747. case VK_LEFT:
  1748. movepieceleft();
  1749. break;
  1750. case VK_RIGHT:
  1751. movepieceright();
  1752. break;
  1753. case VK_UP:
  1754. roatepiece();
  1755. break;
  1756. case VK_DOWN:
  1757. while(newpiece==FALSE)
  1758. {
  1759. movepiecedown();
  1760. }
  1761. checkforrows();
  1762. break;
  1763. }
  1764. }
  1765. CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
  1766. }
  1767. void CRussianGameDlg::OnPause() 
  1768. {
  1769. // TODO: Add your control notification handler code here
  1770. pause=TRUE;
  1771. KillTimer(1);
  1772. }
  1773. int CRussianGameDlg::Random(int MaxNumber)
  1774. {
  1775. unsigned int currentClock = (unsigned)time(NULL);
  1776. srand(currentClock);
  1777. return (rand() % MaxNumber);
  1778. }
  1779. void CRussianGameDlg::OnLineadd() 
  1780. {
  1781. m_iLine++;
  1782. if(m_iLine==16)m_iLine=0;
  1783. Line_num.SetNumber(m_iLine);
  1784. // TODO: Add your control notification handler code here
  1785. }
  1786. void CRussianGameDlg::PaintNextPic()
  1787. {
  1788. CDC *pDC=GetDC();
  1789. CDC memdc;
  1790. memdc.CreateCompatibleDC(pDC);
  1791. memdc.SelectObject(picnext[board.nextpiece]);
  1792. pDC->BitBlt(280,42,80,40,&memdc,1,1,SRCCOPY);
  1793. ReleaseDC(pDC);
  1794. }
  1795. void CRussianGameDlg::OnSound() 
  1796. {
  1797. // TODO: Add your control notification handler code here
  1798. if(FlagSound==FALSE)
  1799. {
  1800. FlagSound=TRUE;
  1801. GetDlgItem(IDC_SOUND)->SetWindowText("无声");
  1802. }
  1803. else
  1804. {
  1805. FlagSound=FALSE;
  1806. GetDlgItem(IDC_SOUND)->SetWindowText("有声");
  1807. }
  1808. }
  1809. BOOL CRussianGameDlg::PreTranslateMessage(MSG* pMsg) 
  1810. {
  1811. // TODO: Add your specialized code here and/or call the base class
  1812. if(pMsg->message==WM_KEYDOWN)
  1813. {
  1814. OnKeyDown((UINT)pMsg->wParam,(UINT)pMsg->lParam,(UINT)pMsg->lParam);
  1815. }
  1816. return CDialog::PreTranslateMessage(pMsg);
  1817. }
  1818. void CRussianGameDlg::writescore()
  1819. {
  1820. AfxGetApp()->WriteProfileInt(_T("英雄榜"),_T("scorenum1"),scorenum[0]);
  1821. AfxGetApp()->WriteProfileInt(_T("英雄榜"),_T("scorenum2"),scorenum[1]);
  1822. AfxGetApp()->WriteProfileInt(_T("英雄榜"),_T("scorenum3"),scorenum[2]);
  1823. AfxGetApp()->WriteProfileInt(_T("英雄榜"),_T("scorenum4"),scorenum[3]);
  1824. AfxGetApp()->WriteProfileInt(_T("英雄榜"),_T("scorenum5"),scorenum[4]);
  1825. AfxGetApp()->WriteProfileString(_T("英雄榜"),_T("scorename1"),scorename[0]);
  1826. AfxGetApp()->WriteProfileString(_T("英雄榜"),_T("scorename2"),scorename[1]);
  1827. AfxGetApp()->WriteProfileString(_T("英雄榜"),_T("scorename3"),scorename[2]);
  1828. AfxGetApp()->WriteProfileString(_T("英雄榜"),_T("scorename4"),scorename[3]);
  1829. AfxGetApp()->WriteProfileString(_T("英雄榜"),_T("scorename5"),scorename[4]);
  1830. }
  1831. BOOL CRussianGameDlg::PlaySounds()
  1832. {
  1833. if(PlaySound(MAKEINTRESOURCE(IDR_WAVESOUND),AfxGetInstanceHandle(),SND_ASYNC|SND_RESOURCE|SND_NODEFAULT))
  1834. return TRUE;
  1835. return FALSE;
  1836. }