destinate.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:35k
源码类别:

游戏

开发平台:

Visual C++

  1. #ifndef DESTINATE_H_
  2. #define DESTINATE_H_
  3. //-----------------//
  4. #include "stdlib.h"
  5. //-----------------//
  6. const int ROW =24;
  7. const int COL =14;
  8. enum VAR;
  9. struct BlockStruct;
  10. class Block;
  11. //----------------//
  12. void GenerateBlock();
  13. bool SetArray(Block & block);
  14. bool ExamArray();
  15. void BreakBlock();
  16. void InitArray();
  17. //----------------//
  18. enum VAR { LL1,LL2,LL3,LL4,
  19. LR5,LR6,LR7,LR8,
  20. C1,C2,C3,C4,
  21. B,
  22. LY1,LY2,
  23. RY1,RY2,
  24. T1,T2
  25. };
  26. //---------------//
  27. struct BlockStruct
  28. {
  29. int red;
  30. int green;
  31. int blue;
  32. bool takeup;
  33. int x;
  34. int y;
  35. };
  36. BlockStruct Array[ROW][COL];
  37. //----------------//
  38. class Block
  39. {
  40. public:
  41. BlockStruct centerpoint;
  42. VAR kind;
  43. public:
  44. Block();
  45. Block(VAR kind,BlockStruct block);
  46. void Generate();
  47. bool LeftOK();
  48. bool RightOK();
  49. bool DownOK();
  50. // bool ShiftOK();
  51. bool Shift();
  52. void Left();
  53. void Right();
  54. void Down();
  55. void ChangeBlock();
  56. void ChangeTrue();
  57. void ChangeFalse();
  58. bool Possiable();
  59. };
  60. //--------------//
  61. void InitArray()
  62. {
  63. int k=0,p=0;
  64. //---------------------//
  65. for(k=0;k<ROW-1;k++)
  66. for(p=1;p<COL-1;p++)
  67. Array[k][p].takeup=false;
  68. //--------------------//
  69. for(k=0;k<ROW;k++)
  70. for(p=0;p<COL;p++)
  71. {
  72. Array[k][p].red=1;
  73. Array[k][p].green=1;
  74. Array[k][p].blue=1;
  75. }
  76. //--------------------//
  77. p=0;
  78. while(p<ROW)
  79. {
  80. Array[p++][0].takeup=true;
  81. }
  82. p=0;
  83. while(p<ROW)
  84. {
  85. Array[p++][COL-1].takeup=true;
  86. }
  87. p=0;
  88. while(p<COL)
  89. {
  90. Array[ROW-1][p++].takeup=true;
  91. }
  92. }
  93. void BreakBlock()
  94. {
  95. int i=1,j=1;
  96. int k,p;
  97. for(j=ROW-2;j>=1;j--)
  98. {
  99. i=1;
  100. while(Array[j][i].takeup)
  101. {
  102. i++;
  103. if(i==COL-2)
  104. {
  105. for(k=j;k>1;k--)
  106. {
  107. p=1;
  108. while(p<COL-1)
  109. {
  110. Array[k][p].takeup=Array[k-1][p].takeup;
  111. p++;
  112. }
  113. }
  114. p=1;
  115. while(p<COL-1)
  116. {
  117. Array[1][p].takeup=false;
  118. p++;
  119. }
  120. break;
  121. }
  122. }
  123. }
  124. }
  125. Block::Block()
  126. {
  127. }
  128. void Block::Generate()
  129. {
  130. int i=rand()%19;
  131. switch(i)
  132. {
  133. case 0: kind=LL1;centerpoint.x=1;break;
  134. case 1: kind=LL2;centerpoint.x=2;break;
  135. case 2: kind=LL3;centerpoint.x=4;break;
  136. case 3: kind=LL4;centerpoint.x=1;break;
  137. case 4: kind=LR5;centerpoint.x=1;break;
  138. case 5: kind=LR6;centerpoint.x=2;break;
  139. case 6: kind=LR7;centerpoint.x=4;break;
  140. case 7: kind=LR8;centerpoint.x=1;break;
  141. case 8: kind=C1; centerpoint.x=1;break;
  142. case 9: kind=C2; centerpoint.x=2;break;
  143. case 10: kind=C3; centerpoint.x=2;break;
  144. case 11: kind=C4; centerpoint.x=2;break;
  145. case 12: kind=B;  centerpoint.x=1;break;
  146. case 13: kind=LY1;centerpoint.x=1;break;
  147. case 14: kind=LY2;centerpoint.x=2;break;
  148. case 15: kind=RY1;centerpoint.x=1;break;
  149. case 16: kind=RY2;centerpoint.x=1;break;
  150. case 17: kind=T1; centerpoint.x=1;break;
  151. case 18: kind=T2; centerpoint.x=1;break;
  152. default:
  153. kind=LL1;
  154. }
  155. centerpoint.y=COL/2;
  156. centerpoint.blue=rand()%255;
  157. centerpoint.green=rand()%255;
  158. centerpoint.red=rand()%255;
  159. }
  160. Block::Block(VAR kind,BlockStruct block)
  161. {
  162. this->kind=kind;
  163. centerpoint=block;
  164. }
  165. /*
  166. bool  Block::LeftOK()
  167. {
  168. switch(this->kind)
  169. {
  170. case LL1:
  171. {
  172.     if(centerpoint.y-1<=0)
  173. return false;
  174. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y-1].takeup&&!Array[centerpoint.x+3][centerpoint.y-1].takeup)
  175. return true;
  176. else
  177. return false;
  178. }
  179. case LL2:
  180. {
  181. if(centerpoint.y-1<=0)
  182. return false;
  183. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x-1][centerpoint.y+2].takeup)
  184. return true;
  185. else
  186. return false;
  187. }
  188. case LL3:
  189. {
  190. if(centerpoint.y-2<=0)
  191. return false;
  192. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x-1][centerpoint.y-1].takeup&&!Array[centerpoint.x-2][centerpoint.y-1].takeup&&!Array[centerpoint.x-3][centerpoint.y-2].takeup)
  193. return true;
  194. else
  195. return false;
  196. }
  197. case LL4:
  198. {
  199. if(centerpoint.y-4<=0)
  200. return false;
  201. if(!Array[centerpoint.x][centerpoint.y-4].takeup&&!Array[centerpoint.x+1][centerpoint.y-4].takeup)
  202. return true;
  203. else
  204. return false;
  205. }
  206. case LR5:
  207. {
  208. if(centerpoint.y-1<=0)
  209. return false;
  210. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y-1].takeup&&!Array[centerpoint.x+3][centerpoint.y-1].takeup)
  211. return true;
  212. else
  213. return false;
  214. }
  215. case LR6:
  216. {
  217. if(centerpoint.y-1<=0)
  218. return false;
  219. if(!Array[centerpoint.x-1][centerpoint.y-1].takeup&&!Array[centerpoint.x][centerpoint.y-1].takeup)
  220. return true;
  221. else
  222. return false;
  223. }
  224. case LR7:
  225. {
  226. if(centerpoint.y-2<=0)
  227. return false;
  228. if(!Array[centerpoint.x][centerpoint.y-2].takeup&&!Array[centerpoint.x-1][centerpoint.y-1].takeup&&!Array[centerpoint.x-2][centerpoint.y-1].takeup&&!Array[centerpoint.x-3][centerpoint.y-1].takeup)
  229. return true;
  230. else
  231. return false;
  232. }
  233. case LR8:
  234. {
  235. if(centerpoint.y-4<=0)
  236. return false;
  237. if(!Array[centerpoint.x][centerpoint.y-4].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup)
  238. return true;
  239. else
  240. return false;
  241. }
  242. case C1 :
  243. {
  244. if(centerpoint.y-2<=0)
  245. return false;
  246. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup)
  247. return true;
  248. else
  249. return false;
  250. }
  251. case C2 :
  252. {
  253. if(centerpoint.y-1<=0)
  254. return false;
  255. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x-1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  256. return true;
  257. else
  258. return false;
  259. }
  260. case C3 :
  261. {
  262. if(centerpoint.y-2<=0)
  263. return false;
  264. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x-1][centerpoint.y-2].takeup)
  265. return true;
  266. else
  267. return false;
  268. }
  269. case C4 :
  270. {
  271. if(centerpoint.y-2<=0)
  272. return false;
  273. if(!Array[centerpoint.x][centerpoint.y-2].takeup&&!Array[centerpoint.x-1][centerpoint.y-2].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup)
  274. return true;
  275. else
  276. return false;
  277. }
  278. case B  :
  279. {
  280. if(centerpoint.y-1<=0)
  281. return false;
  282. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup)
  283. return true;
  284. else
  285. return false;
  286. }
  287. case LY1:
  288. {
  289. if(centerpoint.y-2<=0)
  290. return false;
  291. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup)
  292. return true;
  293. else
  294. return false;
  295. }
  296. case LY2:
  297. {
  298. if(centerpoint.y-1<=0)
  299. return false;
  300. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x-1][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  301. return true;
  302. else
  303. return false;
  304. }
  305. case RY1:
  306. {
  307. if(centerpoint.y-1<=0)
  308. return false;
  309. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  310. return true;
  311. else
  312. return false;
  313. }
  314. case RY2:
  315. {
  316. if(centerpoint.y-2<=0)
  317. return false;
  318. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup&&!Array[centerpoint.x+2][centerpoint.y-2].takeup)
  319. return true;
  320. else
  321. return false;
  322. }
  323. case T1 :
  324. {
  325. if(centerpoint.y-1<=0)
  326. return false;
  327. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y-1].takeup)
  328. return true;
  329. else
  330. return false;
  331. }
  332. case T2 :
  333. {
  334. if(centerpoint.y-1<=0)
  335. return false;
  336. if(!Array[centerpoint.x][centerpoint.y-1].takeup)
  337. return true;
  338. else
  339. return false;
  340. }
  341. default:
  342. {
  343. return false;
  344. }
  345. }
  346. }*/
  347. /*
  348. bool  Block::RightOK()
  349. {
  350. switch(this->kind)
  351. {
  352. case LL1:
  353. {
  354.     if(centerpoint.y+1>=COL-2)
  355. return false;
  356. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup&&!Array[centerpoint.x+3][centerpoint.y+2].takeup)
  357. return true;
  358. else
  359. return false;
  360. }
  361. case LL2:
  362. {
  363.     if(centerpoint.y+3>=COL-2)
  364. return false;
  365. if(!Array[centerpoint.x][centerpoint.y+4].takeup&&!Array[centerpoint.x-1][centerpoint.y+4].takeup)
  366. return true;
  367. else
  368. return false;
  369. }
  370. case LL3:
  371. {
  372.     if(centerpoint.y>=COL-2)
  373. return false;
  374. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x-1][centerpoint.y+1].takeup&&!Array[centerpoint.x-2][centerpoint.y+1].takeup&&!Array[centerpoint.x-3][centerpoint.y+1].takeup)
  375. return true;
  376. else
  377. return false;
  378. }
  379. case LL4:
  380. {
  381.     if(centerpoint.y>=COL-2)
  382. return false;
  383. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup)
  384. return true;
  385. else
  386. return false;
  387. }
  388. case LR5:
  389. {
  390.     if(centerpoint.y+1>=COL-2)
  391. return false;
  392. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup&&!Array[centerpoint.x+3][centerpoint.y+1].takeup)
  393. return true;
  394. else
  395. return false;
  396. }
  397. case LR6:
  398. {
  399.     if(centerpoint.y+3>=COL-2)
  400. return false;
  401. if(!Array[centerpoint.x-1][centerpoint.y+1].takeup&&!Array[centerpoint.x][centerpoint.y+4].takeup)
  402. return true;
  403. else
  404. return false;
  405. }
  406. case LR7:
  407. {
  408.     if(centerpoint.y>=COL-2)
  409. return false;
  410. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x-1][centerpoint.y+1].takeup&&!Array[centerpoint.x-2][centerpoint.y+1].takeup&&!Array[centerpoint.x-3][centerpoint.y+1].takeup)
  411. return true;
  412. else
  413. return false;
  414. }
  415. case LR8:
  416. {
  417.     if(centerpoint.y>=COL-2)
  418. return false;
  419. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup)
  420. return true;
  421. else
  422. return false;
  423. }
  424. case C1 :
  425. {
  426.     if(centerpoint.y+1>=COL-2)
  427. return false;
  428. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup)
  429. return true;
  430. else
  431. return false;
  432. }
  433. case C2 :
  434. {
  435.     if(centerpoint.y+1>=COL-2)
  436. return false;
  437. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x-1][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup)
  438. return true;
  439. else
  440. return false;
  441. }
  442. case C3 :
  443. {
  444.     if(centerpoint.y+1>=COL-2)
  445. return false;
  446. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x-1][centerpoint.y+2].takeup)
  447. return true;
  448. else
  449. return false;
  450. }
  451. case C4 :
  452. {
  453.     if(centerpoint.y>=COL-2)
  454. return false;
  455. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x-1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  456. return true;
  457. else
  458. return false;
  459. }
  460. case B  :
  461. {
  462.     if(centerpoint.y+1>=COL-2)
  463. return false;
  464. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup)
  465. return true;
  466. else
  467. return false;
  468. }
  469. case LY1:
  470. {
  471.     if(centerpoint.y+1>=COL-2)
  472. return false;
  473. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup)
  474. return true;
  475. else
  476. return false;
  477. }
  478. case LY2:
  479. {
  480.     if(centerpoint.y+1>=COL-2)
  481. return false;
  482. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x-1][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup)
  483. return true;
  484. else
  485. return false;
  486. }
  487. case RY1:
  488. {
  489.     if(centerpoint.y+2>=COL-2)
  490. return false;
  491. if(!Array[centerpoint.x][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+3].takeup)
  492. return true;
  493. else
  494. return false;
  495. }
  496. case RY2:
  497. {
  498.     if(centerpoint.y>=COL-2)
  499. return false;
  500. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+2][centerpoint.y].takeup)
  501. return true;
  502. else
  503. return false;
  504. }
  505. case T1 :
  506. {
  507.     if(centerpoint.y>=COL-2)
  508. return false;
  509. if(!Array[centerpoint.x][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup)
  510. return true;
  511. else
  512. return false;
  513. }
  514. case T2 :
  515. {
  516.     if(centerpoint.y+2>=COL-2)
  517. return false;
  518. if(!Array[centerpoint.x][centerpoint.y+3].takeup)
  519. return true;
  520. else
  521. return false;
  522. }
  523. default:
  524. {
  525. return false;
  526. }
  527. }
  528. }
  529. */
  530. // only judge whether it can manipulate  not do action
  531. //只判断不修改centerpoint的值.  
  532. /*
  533. bool Block::DownOK()
  534. {
  535. switch(this->kind)
  536. {
  537. case LL1:
  538. {
  539. if(centerpoint.x+3>=ROW-1)
  540. return false;
  541. if(!Array[centerpoint.x+4][centerpoint.y].takeup&&!Array[centerpoint.x+4][centerpoint.y+1].takeup)
  542. return true;
  543. else
  544. return false;
  545. }
  546. case LL2:
  547. {
  548. if(centerpoint.x>=ROW-1)
  549. return false;
  550. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+3].takeup)
  551. return true;
  552. else
  553. return false;
  554. }
  555. case LL3:
  556. {
  557. if(centerpoint.x>=ROW-1)
  558. return false;
  559. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x-2][centerpoint.y-1].takeup)
  560. return true;
  561. else
  562. return false;
  563. }
  564. case LL4:
  565. {
  566. if(centerpoint.x+1>=ROW-1)
  567. return false;
  568. if(!Array[centerpoint.x+2][centerpoint.y-3].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  569. return true;
  570. else
  571. return false;
  572. }
  573. case LR5:
  574. {
  575. if(centerpoint.x+3>=ROW-1)
  576. return false;
  577. if(!Array[centerpoint.x+4][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup)
  578. return true;
  579. else
  580. return false;
  581. }
  582. case LR6:
  583. {
  584. if(centerpoint.x>=ROW-1)
  585. return false;
  586. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup&&!Array[centerpoint.x+1][centerpoint.y+3].takeup)
  587. return true;
  588. else
  589. return false;
  590. }
  591. case LR7:
  592. {
  593. if(centerpoint.x>=ROW-1)
  594. return false;
  595. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup)
  596. return true;
  597. else
  598. return false;
  599. }
  600. case LR8:
  601. {
  602. if(centerpoint.x+1>=ROW-1)
  603. return false;
  604. if(!Array[centerpoint.x+1][centerpoint.y-3].takeup&&!Array[centerpoint.x+1][centerpoint.y-2].takeup&&!Array[centerpoint.x+1][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y].takeup)
  605. return true;
  606. else
  607. return false;
  608. }
  609. case C1 :
  610. {
  611. if(centerpoint.x+1>=ROW-1)
  612. return false;
  613. if(!Array[centerpoint.x+2][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup)
  614. return true;
  615. else
  616. return false;
  617. }
  618. case C2 :
  619. {
  620. if(centerpoint.x+1>=ROW-1)
  621. return false;
  622. if(!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup)
  623. return true;
  624. else
  625. return false;
  626. }
  627. case C3 :
  628. {
  629. if(centerpoint.x>=ROW-1)
  630. return false;
  631. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x][centerpoint.y-1].takeup&&!Array[centerpoint.x][centerpoint.y+1].takeup)
  632. return true;
  633. else
  634. return false;
  635. }
  636. case C4 :
  637. {
  638. if(centerpoint.x+1>=ROW-1)
  639. return false;
  640. if(!Array[centerpoint.x+2][centerpoint.y-1].takeup&&!Array[centerpoint.x+1][centerpoint.y].takeup)
  641. return true;
  642. else
  643. return false;
  644. }
  645. case B  :
  646. {
  647. if(centerpoint.x+1>=ROW-1)
  648. return false;
  649. if(!Array[centerpoint.x+2][centerpoint.y].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup)
  650. return true;
  651. else
  652. return false;
  653. }
  654. case LY1:
  655. {
  656. if(centerpoint.x+1>=ROW-1)
  657. return false;
  658. if(!Array[centerpoint.x+2][centerpoint.y-1].takeup&&!Array[centerpoint.x+2][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup)
  659. return true;
  660. else
  661. return false;
  662. }
  663. case LY2:
  664. {
  665. if(centerpoint.x+1>=ROW-1)
  666. return false;
  667. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup)
  668. return true;
  669. else
  670. return false;
  671. }
  672. case RY1:
  673. {
  674. if(centerpoint.x+1>=ROW-1)
  675. return false;
  676. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+2][centerpoint.y+1].takeup&&!Array[centerpoint.x+2][centerpoint.y+2].takeup)
  677. return true;
  678. else
  679. return false;
  680. }
  681. case RY2:
  682. {
  683. if(centerpoint.x+2>=ROW-1)
  684. return false;
  685. if(!Array[centerpoint.x+2][centerpoint.y].takeup&&!Array[centerpoint.x+3][centerpoint.y-1].takeup)
  686. return true;
  687. else
  688. return false;
  689. }
  690. case T1 :
  691. {
  692. if(centerpoint.x+2>=ROW-1)
  693. return false;
  694. if(!Array[centerpoint.x+3][centerpoint.y].takeup)
  695. return true;
  696. else
  697. return false;
  698. }
  699. case T2 :
  700. {
  701. if(centerpoint.x>=ROW-1)
  702. return false;
  703. if(!Array[centerpoint.x+1][centerpoint.y].takeup&&!Array[centerpoint.x+1][centerpoint.y+1].takeup&&!Array[centerpoint.x+1][centerpoint.y+2].takeup)
  704. return true;
  705. else
  706. return false;
  707. }
  708. default:
  709. {
  710. return false;
  711. }
  712. }
  713. }*/
  714. bool Block::LeftOK()
  715. {
  716. ChangeFalse();
  717. centerpoint.y-=1;
  718. if(Possiable())
  719. {
  720. centerpoint.y+=1;
  721. return true;
  722. }
  723. else
  724. {
  725. centerpoint.y+=1;
  726. return false;
  727. }
  728. }
  729. bool Block::RightOK()
  730. {
  731. ChangeFalse();
  732. centerpoint.y+=1;
  733. if(Possiable())
  734. {
  735. centerpoint.y-=1;
  736. return true;
  737. }
  738. else
  739. {
  740. centerpoint.y-=1;
  741. return false;
  742. }
  743. }
  744. bool Block::DownOK()
  745. {
  746. ChangeFalse();
  747. centerpoint.x+=1;
  748. if(Possiable())
  749. {
  750. centerpoint.x-=1;
  751. return true;
  752. }
  753. else
  754. {
  755. centerpoint.x-=1;
  756. return false;
  757. }
  758. }
  759. bool Block::Shift()
  760. {
  761. ChangeFalse();
  762. switch(kind)
  763. {
  764. case LL1:
  765. {
  766. centerpoint.x+=2;
  767. centerpoint.y--;
  768. kind=LL2;
  769. if(Possiable())
  770. return true;
  771. else
  772. {
  773. centerpoint.x-=2;
  774. centerpoint.y++;
  775. kind=LL1;
  776. return false;
  777. }
  778. }
  779. case LL2:
  780. {
  781. centerpoint.y+=1;
  782. centerpoint.x+=2;
  783. kind=LL3;
  784. if(Possiable())
  785. return true;
  786. else
  787. {
  788. centerpoint.y-=1;
  789. centerpoint.x-=2;
  790. kind=LL2;
  791. return false;
  792. }
  793. }
  794. case LL3:
  795. {
  796. centerpoint.y+=2;
  797. kind=LL4;
  798. if(Possiable())
  799. return true;
  800. else
  801. {
  802. centerpoint.y-=2;
  803. kind=LL3;
  804. return false;
  805. }
  806. }
  807. case LL4:
  808. {
  809. centerpoint.y-=3;
  810. //centerpoint.x-=2;
  811. kind=LL1;
  812. if(Possiable())
  813. return true;
  814. else
  815. {
  816. centerpoint.y+=3;
  817. // centerpoint.x+=2;
  818. kind=LL4;
  819. return false;
  820. }
  821. }
  822. case LR5:
  823. {
  824. centerpoint.x+=3;
  825. kind=LR6;
  826. if(Possiable())
  827. return true;
  828. else
  829. {
  830. centerpoint.x-=3;
  831. kind=LR5;
  832. return false;
  833. }
  834. }
  835. case LR6:
  836. {
  837. kind=LR7;
  838. centerpoint.x+=1;
  839. if(Possiable())
  840. return true;
  841. else
  842. {
  843. centerpoint.x-=1;
  844. kind=LR6;
  845. return false;
  846. }
  847. }
  848. case LR7:
  849. {
  850. centerpoint.y+=2;
  851. centerpoint.x-=1;
  852. kind=LR8;
  853. if(Possiable())
  854. return true;
  855. else
  856. {
  857. centerpoint.y-=2;
  858. centerpoint.x+=1;
  859. kind=LR7;
  860. return false;
  861. }
  862. }
  863. case LR8:
  864. {
  865. centerpoint.y-=3;
  866. centerpoint.x-=2;
  867. kind=LR5;
  868. if(Possiable())
  869. return true;
  870. else
  871. {
  872. centerpoint.y+=3;
  873. centerpoint.x+=2;
  874. kind=LR8;
  875. return false;
  876. }
  877. }
  878. case C1 :
  879. {
  880. centerpoint.y-=1;
  881. kind=C2;
  882. if(Possiable())
  883. return true;
  884. else
  885. {
  886. centerpoint.y+=1;
  887. kind=C1;
  888. return false;
  889. }
  890. }
  891. case C2 :
  892. {
  893. centerpoint.x+=1;
  894. centerpoint.y+=1;
  895. kind=C3;
  896. if(Possiable())
  897. return true;
  898. else
  899. {
  900. centerpoint.x-=1;
  901. centerpoint.y-=1;
  902. kind=C2;
  903. return false;
  904. }
  905. }
  906. case C3 :
  907. {
  908. centerpoint.x-=1;
  909. kind=C4;
  910. if(Possiable())
  911. return true;
  912. else
  913. {
  914. centerpoint.x+=1;
  915. kind=C3;
  916. return false;
  917. }
  918. }
  919. case C4 :
  920. {
  921. kind=C1;
  922. if(Possiable())
  923. return true;
  924. else
  925. {
  926. kind=C4;
  927. return false;
  928. }
  929. }
  930. case B  :
  931. {
  932. return true;
  933. }
  934. case LY1:
  935. {
  936. centerpoint.y-=1;
  937. kind=LY2;
  938. if(Possiable())
  939. return true;
  940. else
  941. {
  942. centerpoint.y+=1;
  943. kind=LY1;
  944. return false;
  945. }
  946. }
  947. case LY2:
  948. {
  949. centerpoint.y+=1;
  950. kind=LY1;
  951. if(Possiable())
  952. return true;
  953. else
  954. {
  955. centerpoint.y-=1;
  956. kind=LY2;
  957. return false;
  958. }
  959. }
  960. case RY1:
  961. {
  962. centerpoint.y+=1;
  963. centerpoint.x-=1;
  964. kind=RY2;
  965. if(Possiable())
  966. return true;
  967. else
  968. {
  969. centerpoint.y-=1;
  970. centerpoint.x+=1;
  971. kind=RY1;
  972. return false;
  973. }
  974. }
  975. case RY2:
  976. {
  977. centerpoint.x+=1;
  978. centerpoint.y-=1;
  979. kind=RY1;
  980. if(Possiable())
  981. return true;
  982. else
  983. {
  984. centerpoint.x-=1;
  985. centerpoint.y+=1;
  986. kind=RY2;
  987. return false;
  988. }
  989. }
  990. case T1 :
  991. {
  992. centerpoint.x+=1;
  993. centerpoint.y-=1;
  994. kind=T2;
  995. if(Possiable())
  996. return true;
  997. else
  998. {
  999. centerpoint.x-=1;
  1000. centerpoint.y+=1;
  1001. kind=T1;
  1002. return false;
  1003. }
  1004. }
  1005. case T2 :
  1006. {
  1007. centerpoint.x-=1;
  1008. centerpoint.y+=1;
  1009. kind=T1;
  1010. if(Possiable())
  1011. return true;
  1012. else
  1013. {
  1014. centerpoint.x+=1;
  1015. centerpoint.y-=1;
  1016. kind=T2;
  1017. return false;
  1018. }
  1019. }
  1020. default:
  1021. {
  1022. return false;
  1023. }
  1024. }
  1025. }
  1026. void Block::ChangeBlock()
  1027. {
  1028. switch(kind)
  1029. {
  1030. case LL1:
  1031. {
  1032. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1033. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1034. Array[centerpoint.x+2][centerpoint.y]=centerpoint;
  1035. Array[centerpoint.x+3][centerpoint.y]=centerpoint;
  1036. Array[centerpoint.x+3][centerpoint.y+1]=centerpoint;
  1037. break;
  1038. }
  1039. case LL2:
  1040. {
  1041. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1042. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1043. Array[centerpoint.x][centerpoint.y+2]=centerpoint;
  1044. Array[centerpoint.x][centerpoint.y+3]=centerpoint;
  1045. Array[centerpoint.x-1][centerpoint.y+3]=centerpoint;
  1046. break;
  1047. }
  1048. case LL3:
  1049. {
  1050. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1051. Array[centerpoint.x-1][centerpoint.y]=centerpoint;
  1052. Array[centerpoint.x-2][centerpoint.y]=centerpoint;
  1053. Array[centerpoint.x-3][centerpoint.y]=centerpoint;
  1054. Array[centerpoint.x-3][centerpoint.y-1]=centerpoint;
  1055. break;
  1056. }
  1057. case LL4:
  1058. {
  1059. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1060. Array[centerpoint.x][centerpoint.y-1]=centerpoint;
  1061. Array[centerpoint.x][centerpoint.y-2]=centerpoint;
  1062. Array[centerpoint.x][centerpoint.y-3]=centerpoint;
  1063. Array[centerpoint.x+1][centerpoint.y-3]=centerpoint;
  1064. break;
  1065. }
  1066. case LR5:
  1067. {
  1068. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1069. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1070. Array[centerpoint.x+2][centerpoint.y]=centerpoint;
  1071. Array[centerpoint.x+3][centerpoint.y]=centerpoint;
  1072. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1073. break;
  1074. }
  1075. case LR6:
  1076. {
  1077. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1078. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1079. Array[centerpoint.x][centerpoint.y+2]=centerpoint;
  1080. Array[centerpoint.x][centerpoint.y+3]=centerpoint;
  1081. Array[centerpoint.x-1][centerpoint.y]=centerpoint;
  1082. break;
  1083. }
  1084. case LR7:
  1085. {
  1086. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1087. Array[centerpoint.x-1][centerpoint.y]=centerpoint;
  1088. Array[centerpoint.x-2][centerpoint.y]=centerpoint;
  1089. Array[centerpoint.x-3][centerpoint.y]=centerpoint;
  1090. Array[centerpoint.x][centerpoint.y-1]=centerpoint;
  1091. break;
  1092. }
  1093. case LR8:
  1094. {
  1095. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1096. Array[centerpoint.x][centerpoint.y-1]=centerpoint;
  1097. Array[centerpoint.x][centerpoint.y-2]=centerpoint;
  1098. Array[centerpoint.x][centerpoint.y-3]=centerpoint;
  1099. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1100. break;
  1101. }
  1102. case C1 :
  1103. {
  1104. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1105. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1106. Array[centerpoint.x+1][centerpoint.y-1]=centerpoint;
  1107. Array[centerpoint.x+1][centerpoint.y+1]=centerpoint;
  1108. break;
  1109. }
  1110. case C2 :
  1111. {
  1112. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1113. Array[centerpoint.x-1][centerpoint.y+1]=centerpoint;
  1114. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1115. Array[centerpoint.x+1][centerpoint.y+1]=centerpoint;
  1116. break;
  1117. }
  1118. case C3 :
  1119. {
  1120. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1121. Array[centerpoint.x-1][centerpoint.y-1]=centerpoint;
  1122. Array[centerpoint.x-1][centerpoint.y]=centerpoint;
  1123. Array[centerpoint.x-1][centerpoint.y+1]=centerpoint;
  1124. break;
  1125. }
  1126. case C4 :
  1127. {
  1128. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1129. Array[centerpoint.x-1][centerpoint.y-1]=centerpoint;
  1130. Array[centerpoint.x][centerpoint.y-1]=centerpoint;
  1131. Array[centerpoint.x+1][centerpoint.y-1]=centerpoint;
  1132. break;
  1133. }
  1134. case B  :
  1135. {
  1136. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1137. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1138. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1139. Array[centerpoint.x+1][centerpoint.y+1]=centerpoint;
  1140. break;
  1141. }
  1142. case LY1:
  1143. {
  1144. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1145. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1146. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1147. Array[centerpoint.x+1][centerpoint.y-1]=centerpoint;
  1148. break;
  1149. }
  1150. case LY2:
  1151. {
  1152. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1153. Array[centerpoint.x-1][centerpoint.y]=centerpoint;
  1154. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1155. Array[centerpoint.x+1][centerpoint.y+1]=centerpoint;
  1156. break;
  1157. }
  1158. case RY1:
  1159. {
  1160. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1161. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1162. Array[centerpoint.x+1][centerpoint.y+1]=centerpoint;
  1163. Array[centerpoint.x+1][centerpoint.y+2]=centerpoint;
  1164. break;
  1165. }
  1166. case RY2:
  1167. {
  1168. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1169. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1170. Array[centerpoint.x+1][centerpoint.y-1]=centerpoint;
  1171. Array[centerpoint.x+2][centerpoint.y-1]=centerpoint;
  1172. break;
  1173. }
  1174. case T1 :
  1175. {
  1176. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1177. Array[centerpoint.x+1][centerpoint.y]=centerpoint;
  1178. Array[centerpoint.x+2][centerpoint.y]=centerpoint;
  1179. break;
  1180. }
  1181. case T2 :
  1182. {
  1183. Array[centerpoint.x][centerpoint.y]=centerpoint;
  1184. Array[centerpoint.x][centerpoint.y+1]=centerpoint;
  1185. Array[centerpoint.x][centerpoint.y+2]=centerpoint;
  1186. break;
  1187. }
  1188. default:
  1189. {
  1190. return;
  1191. }
  1192. }
  1193. }
  1194. void Block::Left()
  1195. {
  1196. if(LeftOK())
  1197. centerpoint.y--;
  1198. }
  1199. void Block::Right()
  1200. {
  1201. if(RightOK())
  1202. centerpoint.y++;
  1203. }
  1204. void Block::Down()
  1205. {
  1206. if(DownOK())
  1207. centerpoint.x++;
  1208. }
  1209. void  Block::ChangeTrue()
  1210. {
  1211. centerpoint.takeup=true;
  1212. ChangeBlock();
  1213. }
  1214. void  Block::ChangeFalse()
  1215. {
  1216. centerpoint.takeup=false;
  1217. ChangeBlock();
  1218. }
  1219. bool Block::Possiable()
  1220. {
  1221. switch(kind)
  1222. {
  1223. case LL1:
  1224. {
  1225. if(centerpoint.x+3>=ROW-1||centerpoint.y<=0||centerpoint.y+1>=COL-1)
  1226. return false;
  1227. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+2][centerpoint.y].takeup||Array[centerpoint.x+3][centerpoint.y].takeup||Array[centerpoint.x+3][centerpoint.y+1].takeup)
  1228. return false;
  1229. return true;
  1230. }
  1231. case LL2:
  1232. {
  1233. if(centerpoint.x>=ROW-1||centerpoint.y<=0||centerpoint.y+3>=COL-1)
  1234. return false;
  1235. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x][centerpoint.y+2].takeup||Array[centerpoint.x][centerpoint.y+3].takeup||Array[centerpoint.x-1][centerpoint.y+3].takeup)
  1236. return false;
  1237. return true;
  1238. }
  1239. case LL3:
  1240. {
  1241. if(centerpoint.x>=ROW-1||centerpoint.y-1<=0||centerpoint.y>=COL-1)
  1242. return false;
  1243. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y].takeup||Array[centerpoint.x-2][centerpoint.y].takeup||Array[centerpoint.x-3][centerpoint.y].takeup||Array[centerpoint.x-3][centerpoint.y-1].takeup)
  1244. return false;
  1245. return true;
  1246. }
  1247. case LL4:
  1248. {
  1249. if(centerpoint.x+1>=ROW-1||centerpoint.y-3<=0||centerpoint.y>=COL-1)
  1250. return false;
  1251. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y-1].takeup||Array[centerpoint.x][centerpoint.y-2].takeup||Array[centerpoint.x][centerpoint.y-3].takeup||Array[centerpoint.x+1][centerpoint.y-3].takeup)
  1252. return false;
  1253. return true;
  1254. }
  1255. case LR5:
  1256. {
  1257. if(centerpoint.x+3>=ROW-1||centerpoint.y<=0||centerpoint.y+1>=COL-1)
  1258. return false;
  1259. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+2][centerpoint.y].takeup||Array[centerpoint.x+3][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup)
  1260. return false;
  1261. return true;
  1262. }
  1263. case LR6:
  1264. {
  1265. if(centerpoint.x>=ROW-1||centerpoint.y<=0||centerpoint.y+3>=COL-1)
  1266. return false;
  1267. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x][centerpoint.y+2].takeup||Array[centerpoint.x][centerpoint.y+3].takeup||Array[centerpoint.x-1][centerpoint.y].takeup)
  1268. return false;
  1269. return true;
  1270. }
  1271. case LR7:
  1272. {
  1273. if(centerpoint.x>=ROW-1||centerpoint.y-1<=0||centerpoint.y>=COL-1)
  1274. return false;
  1275. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y].takeup||Array[centerpoint.x-2][centerpoint.y].takeup||Array[centerpoint.x-3][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y-1].takeup)
  1276. return false;
  1277. return true;
  1278. }
  1279. case LR8:
  1280. {
  1281. if(centerpoint.x+1>=ROW-1||centerpoint.y-3<=0||centerpoint.y>=COL-1)
  1282. return false;
  1283. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y-1].takeup||Array[centerpoint.x][centerpoint.y-2].takeup||Array[centerpoint.x][centerpoint.y-3].takeup||Array[centerpoint.x+1][centerpoint.y].takeup)
  1284. return false;
  1285. return true;
  1286. }
  1287. case C1 :
  1288. {
  1289. if(centerpoint.x+1>=ROW-1||centerpoint.y-1<=0||centerpoint.y+1>=COL-1)
  1290. return false;
  1291. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y-1].takeup||Array[centerpoint.x+1][centerpoint.y+1].takeup)
  1292. return false;
  1293. return true;
  1294. }
  1295. case C2 :
  1296. {
  1297. if(centerpoint.x+1>=ROW-1||centerpoint.y<=0||centerpoint.y+1>=COL-1)
  1298. return false;
  1299. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y+1].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y+1].takeup)
  1300. return false;
  1301. return true;
  1302. }
  1303. case C3 :
  1304. {
  1305. if(centerpoint.x>=ROW-1||centerpoint.y-1<=0||centerpoint.y+1>=COL-1)
  1306. return false;
  1307. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y-1].takeup||Array[centerpoint.x-1][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y+1].takeup)
  1308. return false;
  1309. return true;
  1310. }
  1311. case C4 :
  1312. {
  1313. if(centerpoint.x+1>=ROW-1||centerpoint.y-1<=0||centerpoint.y>=COL-1)
  1314. return false;
  1315. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y-1].takeup||Array[centerpoint.x][centerpoint.y-1].takeup||Array[centerpoint.x+1][centerpoint.y-1].takeup)
  1316. return false;
  1317. return true;
  1318. }
  1319. case B  :
  1320. {
  1321. if(centerpoint.x+1>=ROW-1||centerpoint.y<=0||centerpoint.y+1>=COL-1)
  1322. return false;
  1323. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y+1].takeup)
  1324. return false;
  1325. return true;
  1326. }
  1327. case LY1:
  1328. {
  1329. if(centerpoint.x+1>=ROW-1||centerpoint.y-1<=0||centerpoint.y+1>=COL-1)
  1330. return false;
  1331. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y-1].takeup)
  1332. return false;
  1333. return true;
  1334. }
  1335. case LY2:
  1336. {
  1337. if(centerpoint.x+1>=ROW-1||centerpoint.y<=0||centerpoint.y+1>=COL-1)
  1338. return false;
  1339. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x-1][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y+1].takeup)
  1340. return false;
  1341. return true;
  1342. }
  1343. case RY1:
  1344. {
  1345. if(centerpoint.x+1>=ROW-1||centerpoint.y<=0||centerpoint.y+2>=COL-1)
  1346. return false;
  1347. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y+1].takeup||Array[centerpoint.x+1][centerpoint.y+2].takeup)
  1348. return false;
  1349. return true;
  1350. }
  1351. case RY2:
  1352. {
  1353. if(centerpoint.x+2>=ROW-1||centerpoint.y-1<=0||centerpoint.y>=COL-1)
  1354. return false;
  1355. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y-1].takeup||Array[centerpoint.x+2][centerpoint.y-1].takeup)
  1356. return false;
  1357. return true;
  1358. }
  1359. case T1 :
  1360. {
  1361. if(centerpoint.x+2>=ROW-1||centerpoint.y<=0||centerpoint.y>=COL-1)
  1362. return false;
  1363. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x+1][centerpoint.y].takeup||Array[centerpoint.x+2][centerpoint.y].takeup)
  1364. return false;
  1365. return true;
  1366. }
  1367. case T2 :
  1368. {
  1369. if(centerpoint.x>=ROW-1||centerpoint.y<=0||centerpoint.y+2>=COL-1)
  1370. return false;
  1371. if(Array[centerpoint.x][centerpoint.y].takeup||Array[centerpoint.x][centerpoint.y+1].takeup||Array[centerpoint.x][centerpoint.y+2].takeup)
  1372. return false;
  1373. return true;
  1374. }
  1375. default:
  1376. {
  1377. return false;
  1378. }
  1379. }
  1380. }
  1381. bool ExamArray()
  1382. {
  1383. int i=1;
  1384. for(i=1;i<COL-1;i++)
  1385. {
  1386. if(Array[0][i].takeup==true)
  1387. {
  1388. return false;   // dead
  1389. }
  1390. }
  1391. return true;// alive
  1392. }
  1393. bool SetArray(Block & block )
  1394. {
  1395. if(!block.LeftOK()&&!block.RightOK()&&!block.DownOK())
  1396. {
  1397. block.ChangeTrue();
  1398. return false; // the block is nonactive 
  1399. //it should generate new block
  1400. }
  1401. return true; // the block is still active;
  1402. }
  1403. #endif