You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

388 lines
7.8 KiB

6 years ago
/****ͷ<>ļ<EFBFBD>****/
#include <stdio.h> //<2F><>׼<EFBFBD><D7BC><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(scanf<6E><66>printf)
#include <windows.h> //<2F><><EFBFBD><EFBFBD>DOS<4F><53><EFBFBD><EFBFBD>(<28><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>á<EFBFBD><C3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
#include <conio.h> //<2F><><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>(kbhit<69><74>getch)
#include <time.h> //<2F><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/****<2A><EFBFBD><EAB6A8>****/
#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>****/
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 MakeTetris(struct Tetris *tetris); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/**
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int color(int c)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);
return 0;
}
/**
*<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
*/
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);
}
/**
*<EFBFBD><EFBFBD>ҳ
*/
void main()
{
/*ͼ<><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;
}
}
/**
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
*/
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,9);
printf("1/ͨ<><CDA8> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>");
gotoxy(16,11);
printf("2/ͨ<><CDA8> <20><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת");
gotoxy(16,13);
printf("3/ͨ<><CDA8> <20><><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
gotoxy(16,15);
printf("4/ͨ<><CDA8><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>Ϸ");
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system("cls");
main();
}
/**
*<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><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();
}
/**
*<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><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><CBB3><EFBFBD>Ϸ");
gotoxy(FrameX,FrameY); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
color(6);
printf("<EFBFBD><EFBFBD>");
gotoxy(FrameX+2*Frame_width-2,FrameY);
printf("<EFBFBD><EFBFBD>");
gotoxy(FrameX,FrameY+Frame_height);
printf("<EFBFBD><EFBFBD>");
gotoxy(FrameX+2*Frame_width-2,FrameY+Frame_height);
printf("<EFBFBD><EFBFBD>");
for(i=2;i<2*Frame_width-2;i+=2)
{
gotoxy(FrameX+i,FrameY);
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD>
}
for(i=2;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=1;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=1;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");
}
/**
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void MakeTetris(struct Tetris *tetris)
{
a[tetris->x][tetris->y]=b[0];
switch(tetris->flag)
{
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(4);
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+1]=b[2];
a[tetris->x][tetris->y+2]=b[3];
break;
}
case 4: //T
{
color(8);
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(8);
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: //˳180T
{
color(11);
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 7: //˳270 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 8: //Z
{
color(14);
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;
}
}
}