|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#define FrameX 13 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻǵ<CFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ13
|
|
|
|
|
#define FrameY 3 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻǵ<CFBD>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ3
|
|
|
|
|
#define Frame_height 20 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD>ڵĸ߶<C4B8>Ϊ20
|
|
|
|
|
#define Frame_width 18 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD>ڵĿ<DAB5><C4BF><EFBFBD>Ϊ18
|
|
|
|
|
/****ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>****/
|
|
|
|
|
int i,j,Temp,Temp1,Temp2; //Temp,Temp1,Temp2<70><32><EFBFBD>ڼ<EFBFBD>ס<EFBFBD><D7A1>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
int a[80][80]={0}; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>Ļ<EFBFBD><C4BB>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>2,1,0 <20>ֱ<EFBFBD><D6B1><EFBFBD>ʾ<EFBFBD><CABE>λ<EFBFBD><CEBB>Ϊ<EFBFBD><CEAA>Ϸ<EFBFBD>߿<DFBF><F2A1A2B7>顢<EFBFBD><E9A1A2>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>
|
|
|
|
|
int b[4]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>Ľṹ<C4BD><E1B9B9>
|
|
|
|
|
struct Tetris
|
|
|
|
|
{
|
|
|
|
|
int x; //<2F><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int y; //<2F><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int flag; //<2F><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int next; //<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int speed; //<2F><><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
int number; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
int score; //<2F><>Ϸ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
int level; //<2F><>Ϸ<EFBFBD>ĵȼ<C4B5>
|
|
|
|
|
} ;
|
|
|
|
|
HANDLE hOut; //<2F><><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
|
|
|
|
|
/****<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>****/
|
|
|
|
|
void HideCursor(); //<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>
|
|
|
|
|
int color(int c); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
|
|
|
|
void gotoxy(int x,int y); //<2F><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
void Game(); //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
void Play(); //<2F><>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
void explation(); //<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
|
|
|
|
|
void rule(); //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
void Make(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void Print(struct Tetris *); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
|
|
|
|
void Clean(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
|
|
|
|
|
int If_move(struct Tetris *); //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD>
|
|
|
|
|
void Shui_Ji(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void Full(struct Tetris *); // <20>жϷ<D0B6><CFB7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>*/
|
|
|
|
|
void HideCursor()
|
|
|
|
|
{
|
|
|
|
|
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
|
|
|
|
|
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
|
|
|
|
|
}
|
|
|
|
|
/**<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD> */
|
|
|
|
|
int color(int c)
|
|
|
|
|
{
|
|
|
|
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> */
|
|
|
|
|
void gotoxy(int x,int y)
|
|
|
|
|
{
|
|
|
|
|
COORD pos;
|
|
|
|
|
pos.X=x; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pos.Y=y; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>ҳ */
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
HideCursor();
|
|
|
|
|
/*ͼ<><CDBC>*/
|
|
|
|
|
color(11);
|
|
|
|
|
gotoxy(20,3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> ˹ <20><> <20><>");
|
|
|
|
|
gotoxy(15,6);
|
|
|
|
|
printf(" <20><>");
|
|
|
|
|
gotoxy(15,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(14);
|
|
|
|
|
gotoxy(26,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(26,7);
|
|
|
|
|
printf(" <20><><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(13);
|
|
|
|
|
gotoxy(40,5);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(40,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(40,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(40,8);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(10);
|
|
|
|
|
gotoxy(50,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(50,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(12);
|
|
|
|
|
gotoxy(60,6);
|
|
|
|
|
printf(" <20><>");
|
|
|
|
|
gotoxy(60,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(9);
|
|
|
|
|
gotoxy(75,5);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
|
|
|
|
|
gotoxy(75,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> <20><> <20><> <20><>");
|
|
|
|
|
gotoxy(75,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><>");
|
|
|
|
|
gotoxy(75,8);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> <20><> <20><> <20><>");
|
|
|
|
|
gotoxy(75,9);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>");
|
|
|
|
|
color(3);
|
|
|
|
|
gotoxy(75,12);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> <20><> ҵ <20><> ѧ");
|
|
|
|
|
gotoxy(75,14);
|
|
|
|
|
printf(" <20><> <20><> <20><> <20><> <20><> ҵ");
|
|
|
|
|
color(6);
|
|
|
|
|
gotoxy(75,16);
|
|
|
|
|
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1806<30><36>");
|
|
|
|
|
gotoxy(75,17);
|
|
|
|
|
printf(" 18408000638");
|
|
|
|
|
gotoxy(75,18);
|
|
|
|
|
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ");
|
|
|
|
|
gotoxy(75,19);
|
|
|
|
|
printf(" 2018<31><38>12<31><32>27<32><37>");
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
int n;
|
|
|
|
|
int i,j=1;
|
|
|
|
|
color(6);
|
|
|
|
|
for(i=9;i<=20;i++)
|
|
|
|
|
{
|
|
|
|
|
for(j=15;j<=65;j++)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j,i);
|
|
|
|
|
if(i==9||i==20)
|
|
|
|
|
{
|
|
|
|
|
printf("=");
|
|
|
|
|
}
|
|
|
|
|
else if(j==15||j==64)
|
|
|
|
|
{
|
|
|
|
|
printf("||");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
color(12);
|
|
|
|
|
gotoxy(25,12);
|
|
|
|
|
printf("1.<2E><>ʼ<EFBFBD><CABC>Ϸ");
|
|
|
|
|
gotoxy(45,12);
|
|
|
|
|
printf("2.<2E><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>");
|
|
|
|
|
gotoxy(25,17);
|
|
|
|
|
printf("3.<2E><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(45,17);
|
|
|
|
|
printf("4.<2E>˳<EFBFBD>");
|
|
|
|
|
gotoxy(21,22);
|
|
|
|
|
color(3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>[1 2 3 4]:[ ]\b\b");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
|
|
|
|
|
switch(n)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
system("cls");
|
|
|
|
|
Game();
|
|
|
|
|
Play();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
explation();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
rule();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5> */
|
|
|
|
|
void explation()
|
|
|
|
|
{
|
|
|
|
|
int i,j = 1;
|
|
|
|
|
system("cls");
|
|
|
|
|
color(6);
|
|
|
|
|
gotoxy(30,3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><> ˵ <20><>");
|
|
|
|
|
for (i = 6; i <= 18; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = 12; j <= 70; j++)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j, i);
|
|
|
|
|
if (i == 6 || i == 18) printf("=");
|
|
|
|
|
else if (j == 12 || j == 69) printf("||");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
color(12);
|
|
|
|
|
gotoxy(16,8);
|
|
|
|
|
printf("1/ͨ<><CDA8> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(16,10);
|
|
|
|
|
printf("2/ͨ<><CDA8> <20><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת");
|
|
|
|
|
gotoxy(16,12);
|
|
|
|
|
printf("3/ͨ<><CDA8> <20><><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(16,14);
|
|
|
|
|
printf("4/ͨ<><CDA8><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>Ϸ");
|
|
|
|
|
gotoxy(16,16);
|
|
|
|
|
printf("5/ͨ<><CDA8> Esc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ");
|
|
|
|
|
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
system("cls");
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> */
|
|
|
|
|
void rule()
|
|
|
|
|
{
|
|
|
|
|
int i,j = 1;
|
|
|
|
|
system("cls");
|
|
|
|
|
color(6);
|
|
|
|
|
gotoxy(30,3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> Ϸ <20><> <20><>");
|
|
|
|
|
for (i = 6; i <= 18; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = 12; j <= 70; j++)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j, i);
|
|
|
|
|
if (i == 6 || i == 18) printf("=");
|
|
|
|
|
else if (j == 12 || j == 69) printf("||");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
color(12);
|
|
|
|
|
gotoxy(16,7);
|
|
|
|
|
printf("1/<2F><>ͬ<EFBFBD><CDAC>״<EFBFBD><D7B4>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(16,9);
|
|
|
|
|
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>úͷ<C3BA><CDB7><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ײ<EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(16,11);
|
|
|
|
|
printf(" һ<>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
color(14);
|
|
|
|
|
gotoxy(16,13);
|
|
|
|
|
printf("2/ÿ<><C3BF><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100");
|
|
|
|
|
color(11);
|
|
|
|
|
gotoxy(16,15);
|
|
|
|
|
printf("3/ÿ<>ۼ<EFBFBD>1000<30>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ȼ<EFBFBD>");
|
|
|
|
|
color(10);
|
|
|
|
|
gotoxy(16,17);
|
|
|
|
|
printf("4/<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȼӿ죬<D3BF><ECA3AC>Ϸ<EFBFBD>ѶȼӴ<C8BC>");
|
|
|
|
|
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
system("cls");
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> */
|
|
|
|
|
void Game()
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+Frame_width-7,FrameY-2);
|
|
|
|
|
color(11);
|
|
|
|
|
printf("<EFBFBD>ҵĶ<EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+7);
|
|
|
|
|
color(2);
|
|
|
|
|
printf("***********");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+6);
|
|
|
|
|
color(3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>飺");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+13);
|
|
|
|
|
color(2);
|
|
|
|
|
printf("***********");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+17);
|
|
|
|
|
color(14);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+19);
|
|
|
|
|
printf("<EFBFBD>ո<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD>Ϸ");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+15);
|
|
|
|
|
printf("Esc:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ");
|
|
|
|
|
|
|
|
|
|
color(6);
|
|
|
|
|
for(i=0;i<=2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+i,FrameY);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<=2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+i,FrameY+Frame_height);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>º<EFBFBD><C2BA><EFBFBD>
|
|
|
|
|
a[FrameX+i][FrameY+Frame_height]=2; //<2F><><EFBFBD><EFBFBD><EFBFBD>º<EFBFBD><C2BA><EFBFBD>Ϊ<EFBFBD><CEAA>Ϸ<EFBFBD>߿<DFBF>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<=Frame_height;i++)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX,FrameY+i);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD>߿<EFBFBD>
|
|
|
|
|
a[FrameX][FrameY+i]=2; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Ϸ<EFBFBD>߿<DFBF>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<=Frame_height;i++)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+2*Frame_width-2,FrameY+i);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>ұ߿<D2B1>
|
|
|
|
|
a[FrameX+2*Frame_width-2][FrameY+i]=2; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Ϸ<EFBFBD>߿<DFBF>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
void Make(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
a[tetris->x][tetris->y]=b[0]; //<2F><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>λ<EFBFBD>õ<EFBFBD>ͼ<EFBFBD><CDBC>״̬
|
|
|
|
|
switch(tetris->flag) //<2F><>7<EFBFBD><37><EFBFBD>࣬19<31><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
case 1: //<2F><>
|
|
|
|
|
{
|
|
|
|
|
color(10);
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 2: //һ
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x+4][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 3: //1
|
|
|
|
|
{
|
|
|
|
|
color(13);
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y-2]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 4: //T
|
|
|
|
|
{
|
|
|
|
|
color(9);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 5: //˳90 T
|
|
|
|
|
{
|
|
|
|
|
color(10);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 6: //˳180 T
|
|
|
|
|
{
|
|
|
|
|
color(11);
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 7: // ˳270 T
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 8: // Z
|
|
|
|
|
{
|
|
|
|
|
color(10);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 9: //˳90 Z
|
|
|
|
|
{
|
|
|
|
|
color(5);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 10: // <20><>Z
|
|
|
|
|
{
|
|
|
|
|
color(9);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 11: //˳90 <20><>Z
|
|
|
|
|
{
|
|
|
|
|
color(13);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 12: // 7
|
|
|
|
|
{
|
|
|
|
|
color(1);
|
|
|
|
|
a[tetris->x][tetris->y-1 ]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 13: // ˳90 7
|
|
|
|
|
{
|
|
|
|
|
color(2);
|
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 14: // ˳180 7
|
|
|
|
|
{
|
|
|
|
|
color(3);
|
|
|
|
|
a[tetris->x][tetris->y-2]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 15: // ˳270 7
|
|
|
|
|
{
|
|
|
|
|
color(4);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+4][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 16: // <20><> 7
|
|
|
|
|
{
|
|
|
|
|
color(9);
|
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 17: // ˳90 <20><>7
|
|
|
|
|
{
|
|
|
|
|
color(10);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 18: // ˳180 <20><>7
|
|
|
|
|
{
|
|
|
|
|
color(11);
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 19: // ˳270 <20><>7
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>*/
|
|
|
|
|
void Print(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
for(i=0;i<4;i++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b[4]<5D>е<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1
|
|
|
|
|
{
|
|
|
|
|
b[i]=1;
|
|
|
|
|
}
|
|
|
|
|
Make(tetris);
|
|
|
|
|
for(i=tetris->x-2;i<=tetris->x+4;i+=2)
|
|
|
|
|
{
|
|
|
|
|
for(j=tetris->y-2;j<=tetris->y+1;j++) //ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>ܳ<EFBFBD><DCB3>ֵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
{
|
|
|
|
|
if(a[i][j]==1&&j>FrameY) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
gotoxy(i,j);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>߿<EFBFBD><DFBF>ڵķ<DAB5><C4B7><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+1);
|
|
|
|
|
color(4);
|
|
|
|
|
printf("<EFBFBD>ȼ<EFBFBD>: ");
|
|
|
|
|
color(12);
|
|
|
|
|
printf("%d",tetris->level);
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+3);
|
|
|
|
|
color(4);
|
|
|
|
|
printf("<EFBFBD>÷<EFBFBD>:");
|
|
|
|
|
color(12);
|
|
|
|
|
printf("%d",tetris->score);
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+5);
|
|
|
|
|
color(4);
|
|
|
|
|
printf("<EFBFBD>ٶ<EFBFBD>:");
|
|
|
|
|
color(12);
|
|
|
|
|
printf("%d ms",tetris->speed);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>Ϸ*/
|
|
|
|
|
void Play()
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
struct Tetris t,*tetris=&t;
|
|
|
|
|
char ch;
|
|
|
|
|
tetris->number=0;
|
|
|
|
|
tetris->speed=300;
|
|
|
|
|
tetris->score=0;
|
|
|
|
|
tetris->level=1;
|
|
|
|
|
HideCursor();
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
Shui_Ji(tetris);
|
|
|
|
|
Temp=tetris->flag;
|
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
|
tetris->flag = tetris->next;
|
|
|
|
|
Print(tetris);
|
|
|
|
|
tetris->x=FrameX+Frame_width;
|
|
|
|
|
tetris->y=FrameY-1;
|
|
|
|
|
tetris->flag=Temp;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
loop:Print(tetris);
|
|
|
|
|
Sleep(tetris->speed); //<2F><>ʱ
|
|
|
|
|
Clean(tetris);
|
|
|
|
|
Temp1=tetris->x;
|
|
|
|
|
Temp2=tetris->flag; //<2F><>ס<EFBFBD><D7A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(kbhit()) //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ch<63><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
ch=getch();
|
|
|
|
|
if(ch==75) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3B6AFA3><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
|
|
|
|
|
{
|
|
|
|
|
tetris->x-=2;
|
|
|
|
|
}
|
|
|
|
|
if(ch==77) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
|
|
|
|
|
{
|
|
|
|
|
tetris->x+=2;
|
|
|
|
|
}
|
|
|
|
|
if(ch==80) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(If_move(tetris)!=0)
|
|
|
|
|
{
|
|
|
|
|
tetris->y+=2;
|
|
|
|
|
}
|
|
|
|
|
if(If_move(tetris)==0)
|
|
|
|
|
{
|
|
|
|
|
tetris->y=FrameY+Frame_height-2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ch==72) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>˳ʱ<CBB3><CAB1>ת90<39><30>
|
|
|
|
|
{
|
|
|
|
|
if( tetris->flag>=2 && tetris->flag<=3 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=2;
|
|
|
|
|
tetris->flag+=2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( tetris->flag>=4 && tetris->flag<=7 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=4;
|
|
|
|
|
tetris->flag+=4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( tetris->flag>=8 && tetris->flag<=9 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=2;
|
|
|
|
|
tetris->flag+=8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( tetris->flag>=10 && tetris->flag<=11 ) //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=2;
|
|
|
|
|
tetris->flag+=10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( tetris->flag>=12 && tetris->flag<=15 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=4;
|
|
|
|
|
tetris->flag+=12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( tetris->flag>=16 && tetris->flag<=19 ) //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=4;
|
|
|
|
|
tetris->flag+=16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(ch == 32) //<2F><><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ
|
|
|
|
|
{
|
|
|
|
|
Print(tetris);
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
if(kbhit()) //<2F>ٰ<EFBFBD><D9B0>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
{
|
|
|
|
|
ch=getch();
|
|
|
|
|
if(ch == 32)
|
|
|
|
|
{
|
|
|
|
|
goto loop;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ch == 27) //esc
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
memset(a,0,6400*sizeof(int)); //<2F><>ʼ<EFBFBD><CABC>a<EFBFBD><61><EFBFBD><EFBFBD>
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
if(If_move(tetris)==0)
|
|
|
|
|
{
|
|
|
|
|
tetris->x=Temp1;
|
|
|
|
|
tetris->flag=Temp2;
|
|
|
|
|
}
|
|
|
|
|
else //<2F><><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>ִ<EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
goto loop;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tetris->y++;
|
|
|
|
|
if(If_move(tetris)==0)
|
|
|
|
|
{
|
|
|
|
|
tetris->y--;
|
|
|
|
|
Print(tetris);
|
|
|
|
|
Full(tetris);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=tetris->y-2;i<tetris->y+2;i++)
|
|
|
|
|
{
|
|
|
|
|
if(i==FrameY)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
gotoxy(29,7);
|
|
|
|
|
printf("\n");
|
|
|
|
|
color(6);
|
|
|
|
|
printf(" @=================================|||||======================================@ \n");
|
|
|
|
|
printf(" || <20><><EFBFBD><EFBFBD> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><><EFBFBD><EFBFBD> <20><> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || \n");
|
|
|
|
|
printf(" |* *| \n");
|
|
|
|
|
color(4);
|
|
|
|
|
printf(" |* *| \n");
|
|
|
|
|
printf(" || <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><> <20><> <20><> <20><> <20><> <20><> <20><> || \n");
|
|
|
|
|
printf(" || <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> || \n");
|
|
|
|
|
printf(" @============================================================================@ \n");
|
|
|
|
|
if(MessageBox(NULL,"<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\nҪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ô?","Game Over",MB_YESNO|MB_ICONQUESTION)==IDYES)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
memset(a,0,6400*sizeof(int));
|
|
|
|
|
Game();
|
|
|
|
|
Play();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tetris->flag = tetris->next;
|
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
|
Clean(tetris);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>*/
|
|
|
|
|
void Clean(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
for(i=0;i<4;i++) //<2F><><EFBFBD><EFBFBD>b[4]<5D><><EFBFBD><EFBFBD>4<EFBFBD><34>Ԫ<EFBFBD>أ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>4<EFBFBD><34>Ԫ<EFBFBD>أ<EFBFBD><D8A3><EFBFBD>ÿ<EFBFBD><C3BF>Ԫ<EFBFBD>ص<EFBFBD>ֵ<EFBFBD><D6B5>Ϊ0
|
|
|
|
|
{
|
|
|
|
|
b[i]=0; //<2F><><EFBFBD><EFBFBD>b[4]<5D><>ÿ<EFBFBD><C3BF>Ԫ<EFBFBD>ص<EFBFBD>ֵ<EFBFBD><D6B5>Ϊ0
|
|
|
|
|
}
|
|
|
|
|
Make(tetris);
|
|
|
|
|
for(i=tetris->x-2;i<=tetris->x+4;i+=2) // XΪ<58><CEAA><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
for(j=tetris->y-2;j<=tetris->y+1;j++)
|
|
|
|
|
{
|
|
|
|
|
if(a[i][j]==0&&j>FrameY) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>浱<EFBFBD><E6B5B1>
|
|
|
|
|
{
|
|
|
|
|
gotoxy(i,j);
|
|
|
|
|
printf(" "); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>*/
|
|
|
|
|
void Shui_Ji(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
tetris->number++; //<2F><>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
srand(time(NULL)); //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(tetris->number==1)
|
|
|
|
|
{
|
|
|
|
|
tetris->flag = rand()%19+1; //<2F><>ס<EFBFBD><D7A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
tetris->next = rand()%19+1; //<2F><>ס<EFBFBD><D7A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A>жϷ<D0B6><CFB7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD> */
|
|
|
|
|
int If_move(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
if(a[tetris->x][tetris->y]!=0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(
|
|
|
|
|
( //<2F><>
|
|
|
|
|
tetris->flag==1 &&
|
|
|
|
|
( a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //һ
|
|
|
|
|
tetris->flag==2 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+4][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //1
|
|
|
|
|
tetris->flag==3 &&
|
|
|
|
|
( a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-2]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //T
|
|
|
|
|
tetris->flag==4 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳90 T
|
|
|
|
|
tetris->flag==5 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳180 T
|
|
|
|
|
tetris->flag==6 &&
|
|
|
|
|
( a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳270 T
|
|
|
|
|
tetris->flag==7 &&
|
|
|
|
|
( a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //Z
|
|
|
|
|
tetris->flag==8 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳90 Z
|
|
|
|
|
tetris->flag==9 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //<2F><> Z
|
|
|
|
|
tetris->flag==10 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳90 <20><>Z
|
|
|
|
|
tetris->flag==11 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //7
|
|
|
|
|
tetris->flag==12 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳90 7
|
|
|
|
|
tetris->flag==13 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y-1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳180 7
|
|
|
|
|
tetris->flag==14 &&
|
|
|
|
|
( a[tetris->x][tetris->y-2]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳270 7
|
|
|
|
|
tetris->flag==15 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+4][tetris->y]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( // <20><> 7
|
|
|
|
|
tetris->flag==16 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( // ˳90 <20><>7
|
|
|
|
|
tetris->flag==17 &&
|
|
|
|
|
( a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳180 <20><>7
|
|
|
|
|
tetris->flag==18 &&
|
|
|
|
|
( a[tetris->x][tetris->y+1]==0&&
|
|
|
|
|
a[tetris->x][tetris->y-1]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y+1]==0)
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
( //˳270 <20><>7
|
|
|
|
|
tetris->flag==19 &&
|
|
|
|
|
( a[tetris->x+2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y]==0&&
|
|
|
|
|
a[tetris->x-2][tetris->y-1]==0)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A>жϷ<D0B6><CFB7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
void Full(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
int k,del_rows=0;
|
|
|
|
|
for(j=FrameY+Frame_height-1;j>=FrameY+1;j--)
|
|
|
|
|
{
|
|
|
|
|
k=0;
|
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
if(a[i][j]==1)
|
|
|
|
|
{
|
|
|
|
|
k++;
|
|
|
|
|
if(k==Frame_width-2)
|
|
|
|
|
{
|
|
|
|
|
for(k=FrameX+2;k<FrameX+2*Frame_width-2;k+=2)
|
|
|
|
|
{
|
|
|
|
|
a[k][j]=0;
|
|
|
|
|
gotoxy(k,j);
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(k=j-1;k>FrameY;k--)
|
|
|
|
|
{
|
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
if(a[i][k]==1)
|
|
|
|
|
{
|
|
|
|
|
a[i][k]=0;
|
|
|
|
|
gotoxy(i,k);
|
|
|
|
|
printf(" ");
|
|
|
|
|
a[i][k+1]=1;
|
|
|
|
|
gotoxy(i,k+1);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
j++; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
del_rows++; //<2F><>¼ɾ<C2BC><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tetris->score+=100*del_rows;
|
|
|
|
|
if( del_rows>0 && ( tetris->score%1000==0 || tetris->score/1000>tetris->level-1 ) )
|
|
|
|
|
{
|
|
|
|
|
tetris->speed-=20;
|
|
|
|
|
tetris->level++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|