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.
my_tetris/俄罗斯方块游戏.c

1023 lines
23 KiB

6 years ago
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
6 years ago
6 years ago
#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
6 years ago
6 years ago
/****ȫ<>ֱ<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>
} ;
6 years ago
int first;
int second;
int third;
6 years ago
HANDLE hOut; //<2F><><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
/****<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>****/
6 years ago
void HideCursor(); //<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>
6 years ago
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>
6 years ago
void Play(); //<2F><>ʼ<EFBFBD><CABC>Ϸ
6 years ago
void explation(); //<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
void rule(); //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
6 years ago
void Ji_Lu(); //<2F><>Ϸ<EFBFBD><CFB7>¼
6 years ago
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>
6 years ago
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>
6 years ago
void Full(struct Tetris *); // <20>жϷ<D0B6><CFB7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
6 years ago
void tihuan(int n,int x,int y,int z);
6 years ago
void panduan(int x);
6 years ago
/*<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> */
6 years ago
int color(int c)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);
return 0;
}
6 years ago
/*<2A><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> */
6 years ago
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);
}
6 years ago
/*<2A><>ҳ */
int main()
6 years ago
{
6 years ago
6 years ago
HideCursor();
6 years ago
FILE *fp;
fp=fopen("f1.txt","w");
fclose(fp);
6 years ago
/*ͼ<><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);
6 years ago
printf("4.<2E><>Ϸ<EFBFBD><CFB7>¼");
6 years ago
gotoxy(21,22);
color(3);
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>");
gotoxy(21,24);
6 years ago
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>[1 2 3 4]:[ ]\b\b");
scanf("%d",&n);
6 years ago
printf("\a\a\a\a");
6 years ago
switch(n)
{
case 1:
system("cls");
Game();
6 years ago
Play();
6 years ago
break;
case 2:
explation();
break;
case 3:
rule();
break;
case 4:
6 years ago
Ji_Lu();
6 years ago
break;
6 years ago
default:
break;
6 years ago
}
6 years ago
return 0;
6 years ago
}
6 years ago
/*<2A><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5> */
6 years ago
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);
6 years ago
gotoxy(16,8);
6 years ago
printf("1/ͨ<><CDA8> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>");
6 years ago
gotoxy(16,10);
6 years ago
printf("2/ͨ<><CDA8> <20><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת");
6 years ago
gotoxy(16,12);
6 years ago
printf("3/ͨ<><CDA8> <20><><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
6 years ago
gotoxy(16,14);
6 years ago
printf("4/ͨ<><CDA8><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>Ϸ");
6 years ago
gotoxy(16,16);
printf("5/ͨ<><CDA8> Esc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ");
6 years ago
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system("cls");
main();
}
6 years ago
/*<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> */
6 years ago
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();
}
6 years ago
6 years ago
/*<2A><>¼*/
void Ji_Lu()
{
int i,j = 1;
system("cls");
color(6);
gotoxy(30,3);
printf("<EFBFBD><EFBFBD> Ϸ <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("||");
}
}
FILE *fp;
6 years ago
fp=fopen("f1.txt","r+");
fscanf(fp,"%d%d%d",&first,&second,&third);
6 years ago
color(12);
gotoxy(30,9);
6 years ago
printf("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d<><64>",first);
6 years ago
color(10);
gotoxy(30,12);
6 years ago
printf("<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d<><64>",second);
6 years ago
color(11);
gotoxy(30,15);
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d<><64>",third);
6 years ago
fclose(fp);
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system("cls");
main();
}
/*<2A>ж<EFBFBD>*/
6 years ago
void panduan(int n)
6 years ago
{
FILE *fp;
6 years ago
fp=fopen("f1.txt","r");
fscanf(fp,"%d%d%d",&first,&second,&third);
fclose(fp);
if(n>third)
6 years ago
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼Ŷ!!!");
6 years ago
tihuan(n,first,second,third);
fp=fopen("f1.txt","w");
fprintf(fp,"%d %d %d",first,second,third);
fclose(fp);
6 years ago
}
6 years ago
6 years ago
}
6 years ago
/*<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> */
6 years ago
void Game()
{
gotoxy(FrameX+Frame_width-7,FrameY-2);
color(11);
6 years ago
printf("<EFBFBD>ҵĶ<EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
6 years ago
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);
6 years ago
printf("Esc:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ");
6 years ago
color(6);
6 years ago
for(i=0;i<=2*Frame_width-2;i+=2)
6 years ago
{
gotoxy(FrameX+i,FrameY);
printf("<EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD>
}
6 years ago
for(i=0;i<=2*Frame_width-2;i+=2)
6 years ago
{
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>
}
6 years ago
for(i=0;i<=Frame_height;i++)
6 years ago
{
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>
}
6 years ago
for(i=0;i<=Frame_height;i++)
6 years ago
{
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");
}
6 years ago
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
6 years ago
void Make(struct Tetris *tetris)
6 years ago
{
6 years ago
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>
6 years ago
{
6 years ago
case 1: //<2F><>
6 years ago
{
color(10);
6 years ago
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;
6 years ago
}
6 years ago
case 3: //1
6 years ago
{
6 years ago
color(13);
a[tetris->x][tetris->y-1]=b[1];
6 years ago
a[tetris->x][tetris->y-2]=b[2];
a[tetris->x][tetris->y+1]=b[3];
6 years ago
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;
6 years ago
}
6 years ago
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
6 years ago
{
color(13);
6 years ago
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);
6 years ago
a[tetris->x][tetris->y-1 ]=b[1];
6 years ago
a[tetris->x][tetris->y+1]=b[2];
6 years ago
a[tetris->x-2][tetris->y-1]=b[3];
6 years ago
break;
6 years ago
}
6 years ago
case 13: // ˳90 7
6 years ago
{
6 years ago
color(2);
6 years ago
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];
6 years ago
break;
6 years ago
}
6 years ago
case 14: // ˳180 7
6 years ago
{
6 years ago
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;
6 years ago
}
6 years ago
case 15: // ˳270 7
6 years ago
{
6 years ago
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;
6 years ago
}
6 years ago
case 16: // <20><> 7
6 years ago
{
color(9);
6 years ago
a[tetris->x+2][tetris->y-1]=b[1];
6 years ago
a[tetris->x][tetris->y+1]=b[2];
6 years ago
a[tetris->x][tetris->y-1]=b[3];
6 years ago
break;
6 years ago
}
6 years ago
case 17: // ˳90 <20><>7
6 years ago
{
6 years ago
color(10);
a[tetris->x-2][tetris->y]=b[1];
6 years ago
a[tetris->x+2][tetris->y]=b[2];
a[tetris->x+2][tetris->y+1]=b[3];
6 years ago
break;
6 years ago
}
6 years ago
case 18: // ˳180 <20><>7
{
color(11);
6 years ago
a[tetris->x][tetris->y+1]=b[1];
6 years ago
a[tetris->x][tetris->y-1]=b[2];
6 years ago
a[tetris->x-2][tetris->y+1]=b[3];
6 years ago
break;
}
case 19: // ˳270 <20><>7
{
color(12);
a[tetris->x+2][tetris->y]=b[1];
6 years ago
a[tetris->x-2][tetris->y]=b[2];
a[tetris->x-2][tetris->y-1]=b[3];
6 years ago
break;
}
6 years ago
}
}
6 years ago
6 years ago
/*<2A><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>*/
6 years ago
void Print(struct Tetris *tetris)
6 years ago
{
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;
}
6 years ago
Make(tetris);
6 years ago
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);
}
6 years ago
/* <20><>ʼ<EFBFBD><CABC>Ϸ*/
6 years ago
void Play()
6 years ago
{
int n;
6 years ago
struct Tetris t,*tetris=&t;
char ch;
tetris->number=0;
6 years ago
tetris->speed=250;
6 years ago
tetris->score=0;
6 years ago
tetris->level=1;
HideCursor();
6 years ago
while(1)
6 years ago
{
6 years ago
Shui_Ji(tetris);
6 years ago
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;
6 years ago
tetris->flag=Temp;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
6 years ago
while(1)
6 years ago
{
6 years ago
loop:Print(tetris);
6 years ago
Sleep(tetris->speed); //<2F><>ʱ
6 years ago
Clean(tetris);
6 years ago
Temp1=tetris->x;
6 years ago
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();
6 years ago
if(ch==75) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󶯣<EFBFBD><F3B6AFA3><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
6 years ago
{
tetris->x-=2;
}
6 years ago
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
6 years ago
{
tetris->x+=2;
}
6 years ago
if(ch==80) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
6 years ago
{
6 years ago
if(If_move(tetris)!=0)
6 years ago
{
tetris->y+=2;
}
6 years ago
if(If_move(tetris)==0)
6 years ago
{
tetris->y=FrameY+Frame_height-2;
}
}
6 years ago
if(ch==72) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>˳ʱ<CBB3><CAB1>ת90<39><30>
6 years ago
{
if( tetris->flag>=2 && tetris->flag<=3 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>
{
tetris->flag++;
tetris->flag%=2;
tetris->flag+=2;
}
6 years ago
6 years ago
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;
}
6 years ago
if( tetris->flag>=8 && tetris->flag<=9 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
6 years ago
{
tetris->flag++;
6 years ago
tetris->flag%=2;
6 years ago
tetris->flag+=8;
}
6 years ago
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;
}
6 years ago
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;
}
6 years ago
6 years ago
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;
}
6 years ago
6 years ago
}
if(ch == 32) //<2F><><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ
{
6 years ago
Print(tetris);
6 years ago
while(1)
{
if(kbhit()) //<2F>ٰ<EFBFBD><D9B0>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
{
ch=getch();
if(ch == 32)
{
6 years ago
goto loop;
6 years ago
}
}
}
}
6 years ago
if(ch == 27) //esc
6 years ago
{
system("cls");
memset(a,0,6400*sizeof(int)); //<2F><>ʼ<EFBFBD><CABC>a<EFBFBD><61><EFBFBD><EFBFBD>
6 years ago
main();
6 years ago
}
6 years ago
if(If_move(tetris)==0)
6 years ago
{
tetris->x=Temp1;
tetris->flag=Temp2;
}
else //<2F><><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>ִ<EFBFBD>в<EFBFBD><D0B2><EFBFBD>
{
6 years ago
goto loop;
6 years ago
}
}
6 years ago
tetris->y++;
6 years ago
if(If_move(tetris)==0)
6 years ago
{
tetris->y--;
6 years ago
Print(tetris);
Full(tetris);
6 years ago
break;
}
}
for(i=tetris->y-2;i<tetris->y+2;i++)
{
if(i==FrameY)
6 years ago
{ panduan(tetris->score);
6 years ago
system("cls");
gotoxy(29,7);
printf("\n");
color(6);
6 years ago
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");
6 years ago
color(4);
6 years ago
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");
6 years ago
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)
6 years ago
{
system("cls");
memset(a,0,6400*sizeof(int));
6 years ago
main();
6 years ago
}
6 years ago
else
exit(0);
}
}
6 years ago
tetris->flag = tetris->next;
6 years ago
tetris->x=FrameX+2*Frame_width+6;
tetris->y=FrameY+10;
6 years ago
Clean(tetris);
}
}
6 years ago
6 years ago
void tihuan(int n,int x,int y,int z)
6 years ago
{
6 years ago
if(n>x)
6 years ago
{
6 years ago
z=y;
y =x;
x=n;
6 years ago
}
6 years ago
else if(n<x&&n>y )
6 years ago
{
6 years ago
z =y;
y =n;
6 years ago
}
6 years ago
else if(n<y&&n>z )
6 years ago
{
6 years ago
z=n;
6 years ago
}
}
6 years ago
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>*/
6 years ago
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);
6 years ago
for(i=tetris->x-2;i<=tetris->x+4;i+=2) // XΪ<58><CEAA><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
6 years ago
{
6 years ago
for(j=tetris->y-2;j<=tetris->y+1;j++)
6 years ago
{
6 years ago
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>
6 years ago
{
gotoxy(i,j);
printf(" "); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
6 years ago
printf("\a");
6 years ago
}
6 years ago
}
}
6 years ago
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>*/
6 years ago
void Shui_Ji(struct Tetris *tetris)
6 years ago
{
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> */
6 years ago
int If_move(struct Tetris *tetris)
6 years ago
{
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&&
6 years ago
a[tetris->x+2][tetris->y+1]==0&&
a[tetris->x+2][tetris->y]==0)
6 years ago
)
||
( //˳180 <20><>7
tetris->flag==18 &&
6 years ago
( a[tetris->x][tetris->y+1]==0&&
6 years ago
a[tetris->x][tetris->y-1]==0&&
6 years ago
a[tetris->x-2][tetris->y+1]==0)
6 years ago
)
||
( //˳270 <20><>7
tetris->flag==19 &&
( a[tetris->x+2][tetris->y]==0&&
6 years ago
a[tetris->x-2][tetris->y]==0&&
a[tetris->x-2][tetris->y-1]==0)
6 years ago
)
)
{
return 1;
}
}
return 0;
}
6 years ago
6 years ago
/*<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++;
}
}