|
|
|
|
/*******ͷ <20><> <20><>*******/
|
|
|
|
|
#include <stdio.h> //<2F><><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣨printf<74><66>scanf<6E><66>
|
|
|
|
|
#include <windows.h> //<2F><><EFBFBD><EFBFBD>dos<6F><73><EFBFBD>棨<EFBFBD><E6A3A8>ȡ<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><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>kbhit()<29><>getch()<29><>
|
|
|
|
|
#include <time.h> //<2F><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/*******<2A><> <20><> <20><>*******/
|
|
|
|
|
#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>Ϊ13
|
|
|
|
|
#define Frame_height 20 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD>ڵĸ߶<C4B8>Ϊ20
|
|
|
|
|
#define Frame_width 18 //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD>ڵĿ<DAB5><C4BF><EFBFBD>Ϊ18
|
|
|
|
|
/*******<2A><> <20><> ȫ <20><> <20><> <20><> *******/
|
|
|
|
|
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>ֵ
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>Ļ<EFBFBD><C4BB>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>2,1,0<>ֱ<EFBFBD><D6B1><EFBFBD>ʾ<EFBFBD><CABE>λ<EFBFBD><CEBB>Ϊ<EFBFBD><CEAA>Ϸ<EFBFBD>߿<DFBF><F2A1A2B7>顢<EFBFBD><E9A1A2>ͼ<EFBFBD><CDBC>;<3B><>ʼ<EFBFBD><CABC>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>
|
|
|
|
|
int a[80][80]={0};
|
|
|
|
|
int b[4]; //<2F><><EFBFBD><EFBFBD>4<EFBFBD><34>"<22><>"<22><><EFBFBD>飺1<E9A3BA><31>ʾ<EFBFBD>з<EFBFBD><D0B7>飬0<E9A3AC><30>ʾ<EFBFBD><EFBFBD><DEB7><EFBFBD>
|
|
|
|
|
struct Tetris //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>Ľṹ<C4BD><E1B9B9>
|
|
|
|
|
{
|
|
|
|
|
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><> <20><> <20><> <20><> *******/
|
|
|
|
|
int color(int c); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void gotoxy(int x, int y); //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ָ<EFBFBD><D6B8>λ<EFBFBD><CEBB>
|
|
|
|
|
void DrwaGameframe(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>߿<EFBFBD>
|
|
|
|
|
void Flag(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void MakeTetris(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
void PrintTetris(struct Tetris *); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
void CleanTetris(struct Tetris *); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>ĺۼ<C4BA>
|
|
|
|
|
int ifMove(struct Tetris *); //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ1<CEAA><31><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2A3ACB2><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
void Del_Fullline(struct Tetris *); //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
void Gameplay(); //<2F><>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
void regulation(); //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
void explation(); //<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
|
|
|
|
|
void welcom(); //<2F><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD>
|
|
|
|
|
void Replay(struct Tetris * tetris); //<2F><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
void title(); //<2F><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
void flower(); //<2F><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ַ<EFBFBD>װ<EFBFBD>λ<EFBFBD>
|
|
|
|
|
void close();
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>1<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>Windowsϵͳ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> 2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸı䱳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
*/
|
|
|
|
|
int color(int c)
|
|
|
|
|
{
|
|
|
|
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
return 0;
|
|
|
|
|
} //<2F>ر<EFBFBD><D8B1><EFBFBD>Ϸ
|
|
|
|
|
/**
|
|
|
|
|
* <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>ӭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void title()
|
|
|
|
|
{
|
|
|
|
|
color(15); //<2F><><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
gotoxy(28,3);
|
|
|
|
|
printf("Ȥ ζ <20><> <20><> ˹ <20><> <20><>\n"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
color(11); //<2F><><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
gotoxy(18,5);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>
|
|
|
|
|
gotoxy(18,6); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //<2F><>
|
|
|
|
|
gotoxy(18,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(14); //<2F><>ɫ
|
|
|
|
|
gotoxy(26,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(28,7); // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(10); //<2F><>ɫ
|
|
|
|
|
gotoxy(36,6); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(36,7);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(13); //<2F><>ɫ
|
|
|
|
|
gotoxy(45,5);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>
|
|
|
|
|
gotoxy(45,6); //<2F><>
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); //<2F><>
|
|
|
|
|
gotoxy(45,7); //<2F><>
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(45,8);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>");
|
|
|
|
|
|
|
|
|
|
color(12); //<2F><><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
gotoxy(56,6);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>"); // <20><>
|
|
|
|
|
gotoxy(52,7); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>˵<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void welcom()
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
int i,j = 1;
|
|
|
|
|
color(14); //<2F><>ɫ<EFBFBD>߿<EFBFBD>
|
|
|
|
|
for (i = 9; i <= 20; i++) //ѭ<><D1AD>y<EFBFBD><79><EFBFBD><EFBFBD><EFBFBD>꣬<EFBFBD><EAA3AC>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±߿<C2B1>===
|
|
|
|
|
{
|
|
|
|
|
for (j = 15; j <= 60; j++) //ѭ<><D1AD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD>꣬<EFBFBD><EAA3AC>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ߿<D2B1>||
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j, i);
|
|
|
|
|
if (i == 9 || i == 20) printf("="); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±߿<C2B1>===
|
|
|
|
|
else if (j == 15 || j == 59) printf("||"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ߿<D2B1>||
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>˵<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
color(12); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫΪ<C9AB><CEAA>ɫ
|
|
|
|
|
gotoxy(25, 12); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
|
|
|
|
|
printf("1.<2E><>ʼ<EFBFBD><CABC>Ϸ"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>1.<2E><>ʼ<EFBFBD><CABC>Ϸ<EFBFBD><CFB7>
|
|
|
|
|
gotoxy(40, 12);
|
|
|
|
|
printf("2.<2E><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>");
|
|
|
|
|
gotoxy(25, 17);
|
|
|
|
|
printf("3.<2E><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(40, 17);
|
|
|
|
|
printf("4.<2E>˳<EFBFBD>");
|
|
|
|
|
gotoxy(21,22);
|
|
|
|
|
color(3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>[1 2 3 4]:[ ]\b\b");
|
|
|
|
|
color(14);
|
|
|
|
|
scanf("%d", &n); //<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|
|
|
|
switch (n)
|
|
|
|
|
{
|
|
|
|
|
case 1: //<2F><><EFBFBD><EFBFBD>1
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
DrwaGameframe();
|
|
|
|
|
Gameplay();
|
|
|
|
|
break;
|
|
|
|
|
case 2: //<2F><><EFBFBD><EFBFBD>2
|
|
|
|
|
explation();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
regulation(); //<2F><><EFBFBD><EFBFBD>3
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
close(); //<2F><><EFBFBD><EFBFBD>4
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void DrwaGameframe()
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+Frame_width-5,FrameY-2); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʾλ<CABE><CEBB>
|
|
|
|
|
color(11); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
printf("Ȥζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //<2F><>ӡ<EFBFBD><D3A1>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+7); //<2F><><EFBFBD><EFBFBD><EFBFBD>ϱ߿<CFB1><DFBF><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
|
|
|
|
|
color(2); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
printf("**********"); //<2F><>ӡ<EFBFBD><D3A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ߿<CFB1>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+13,FrameY+7);
|
|
|
|
|
color(3); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
printf("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>飺");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+13);
|
|
|
|
|
color(2);
|
|
|
|
|
printf("**********"); //<2F><>ӡ<EFBFBD><D3A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±߿<C2B1>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+17);
|
|
|
|
|
color(14); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ɫ
|
|
|
|
|
printf("<EFBFBD><EFBFBD><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 <20><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>Ϸ");
|
|
|
|
|
gotoxy(FrameX,FrameY);
|
|
|
|
|
color(12);
|
|
|
|
|
printf("<EFBFBD>X"); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width-2,FrameY);
|
|
|
|
|
printf("<EFBFBD>[");
|
|
|
|
|
gotoxy(FrameX,FrameY+Frame_height);
|
|
|
|
|
printf("<EFBFBD>^");
|
|
|
|
|
gotoxy(FrameX+2*Frame_width-2,FrameY+Frame_height);
|
|
|
|
|
printf("<EFBFBD>a");
|
|
|
|
|
a[FrameX][FrameY+Frame_height]=2; //<2F><>ס<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|
|
|
|
a[FrameX+2*Frame_width-2][FrameY+Frame_height]=2;
|
|
|
|
|
for(i=2;i<2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+i,FrameY);
|
|
|
|
|
printf("<EFBFBD>T"); //<2F><>ӡ<EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
for(i=2;i<2*Frame_width-2;i+=2)
|
|
|
|
|
{
|
|
|
|
|
gotoxy(FrameX+i,FrameY+Frame_height);
|
|
|
|
|
printf("<EFBFBD>T"); //<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>U"); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><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>U"); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void MakeTetris(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: /*<2A><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
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: /*ֱ<>߷<EFBFBD><DFB7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
color(13);
|
|
|
|
|
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: /*ֱ<>߷<EFBFBD><DFB7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
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<>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
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 5: /* ˳ʱ<CBB3><CAB1>90<39><30>T<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
color(11);
|
|
|
|
|
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 6: /* ˳ʱ<CBB3><CAB1>180<38><30>T<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
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: /* ˳ʱ<CBB3><CAB1>270<37><30>T<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(11);
|
|
|
|
|
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<>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
color(14);
|
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 9: /* ˳ʱ<CBB3><CAB1>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(14);
|
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 10: /* <20><>תZ<D7AA>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(14);
|
|
|
|
|
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 11: /* ˳ʱ<CBB3><CAB1>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(14);
|
|
|
|
|
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 12: /* 7<>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
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: /* ˳ʱ<CBB3><CAB1>90<39><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 14: /* ˳ʱ<CBB3><CAB1>180<38><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
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 15: /* ˳ʱ<CBB3><CAB1>270<37><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 16: /* <20><>ת7<D7AA>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
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 17: /* ˳ʱ<CBB3><CAB1>ת90<39><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 18: /* ˳ʱ<CBB3><CAB1>ת180<38><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
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: /* ˳ָ<CBB3><D6B8>ת270<37><30>7<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
color(12);
|
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void PrintTetris(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>Ϊ1
|
|
|
|
|
{
|
|
|
|
|
b[i]=1; //<2F><><EFBFBD><EFBFBD>b[4]<5D><>ÿ<EFBFBD><C3BF>Ԫ<EFBFBD>ص<EFBFBD>ֵ<EFBFBD><D6B5>Ϊ1
|
|
|
|
|
}
|
|
|
|
|
MakeTetris(tetris); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
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><D0BF>ܳ<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>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ӡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+1); //<2F><><EFBFBD>ô<EFBFBD>ӡλ<D3A1><CEBB>
|
|
|
|
|
color(4);
|
|
|
|
|
printf("level : ");
|
|
|
|
|
color(12);
|
|
|
|
|
printf(" %d",tetris->level); //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+3);
|
|
|
|
|
color(4);
|
|
|
|
|
printf("score : ");
|
|
|
|
|
color(12);
|
|
|
|
|
printf(" %d",tetris->score); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(FrameX+2*Frame_width+3,FrameY+5);
|
|
|
|
|
color(4);
|
|
|
|
|
printf("speed : ");
|
|
|
|
|
color(12);
|
|
|
|
|
printf(" %dms",tetris->speed); //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int ifMove(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
if(a[tetris->x][tetris->y]!=0)//<2F><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(
|
|
|
|
|
( tetris->flag==1 && ( a[tetris->x][tetris->y-1]==0 &&/*<2A><>Ϊ<EFBFBD><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>λ
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<EFBFBD><EFBFBD>"<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>飬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>*/
|
|
|
|
|
a[tetris->x+2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
//<2F><>Ϊֱ<CEAA>߷<EFBFBD><DFB7><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD>"<22><>"<22>ַ<EFBFBD><D6B7><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ1<CEAA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
( tetris->flag==2 && ( a[tetris->x-2][tetris->y]==0 &&
|
|
|
|
|
a[tetris->x+2][tetris->y]==0 && a[tetris->x+4][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==3 && ( a[tetris->x][tetris->y-1]==0 && //ֱ<>߷<EFBFBD><DFB7>飨<EFBFBD><E9A3A8><EFBFBD><EFBFBD>
|
|
|
|
|
a[tetris->x][tetris->y-2]==0 && a[tetris->x][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==4 && ( a[tetris->x-2][tetris->y]==0 && //T<>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==5 && ( a[tetris->x][tetris->y-1]==0 && //T<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>90<39>㣩
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==6 && ( a[tetris->x][tetris->y-1]==0 && //T<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>180<38>㣩
|
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==7 && ( a[tetris->x][tetris->y-1]==0 && //T<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>270<37>㣩
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==8 && ( a[tetris->x][tetris->y+1]==0 && //Z<>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==9 && ( a[tetris->x][tetris->y-1]==0 && //Z<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>180<38>㣩
|
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x-2][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==10 && ( a[tetris->x][tetris->y-1]==0 && //Z<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת<EFBFBD><D7AA>
|
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==11 && ( a[tetris->x][tetris->y+1]==0 &&//Z<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת+˳ʱ<CBB3><CAB1>180<38>㣩
|
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x-2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==12 && ( a[tetris->x][tetris->y-1]==0 && //7<>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y-1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==15 && ( a[tetris->x-2][tetris->y]==0 && //7<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>90<39>㣩
|
|
|
|
|
a[tetris->x-2][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==14 && ( a[tetris->x][tetris->y-1]==0 && //7<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>180<38>㣩
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==13 && ( a[tetris->x-2][tetris->y]==0 && //7<>ַ<EFBFBD><D6B7>飨˳ʱ<CBB3><CAB1>270<37>㣩
|
|
|
|
|
a[tetris->x+2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==16 && ( a[tetris->x][tetris->y+1]==0 && //7<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת<EFBFBD><D7AA>
|
|
|
|
|
a[tetris->x][tetris->y-1]==0 && a[tetris->x+2][tetris->y-1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==19 && ( a[tetris->x-2][tetris->y]==0 &&//7<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת+˳ʱ<CBB3><CAB1>90<39>㣩
|
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
|
( tetris->flag==18 && ( a[tetris->x][tetris->y-1]==0 &&//7<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת+˳ʱ<CBB3><CAB1>180<38>㣩
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y+1]==0 ) ) ||
|
|
|
|
|
( tetris->flag==17 && ( a[tetris->x-2][tetris->y]==0 &&//7<>ַ<EFBFBD><D6B7>飨<EFBFBD><E9A3A8>ת+˳ʱ<CBB3><CAB1>270<37>㣩
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) )
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺۼ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void CleanTetris(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
MakeTetris(tetris); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
for( i = tetris->x - 2;i <= tetris->x + 4; i+=2 ) //<2F><>X<EFBFBD><58><EFBFBD><EFBFBD> XΪ<58><CEAA><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
for(j = tetris->y-2;j <= tetris->y + 1;j++) /* <20><>
|
|
|
|
|
<EFBFBD><EFBFBD>
|
|
|
|
|
X
|
|
|
|
|
<EFBFBD><EFBFBD> */
|
|
|
|
|
{
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void Del_Fullline(struct Tetris *tetris) //<2F><>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>Frame_width-2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
int k,del_rows=0; //<2F>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ڼ<EFBFBD>¼ij<C2BC>з<EFBFBD><D0B7><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
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) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
k++; //<2F><>¼<EFBFBD><C2BC><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
if(k==Frame_width-2) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
for(k=FrameX+2;k<FrameX+2*Frame_width-2;k+=2) //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>еķ<D0B5><C4B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
a[k][j]=0;
|
|
|
|
|
gotoxy(k,j);
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>з<EFBFBD><D0B7>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD><CEBB>
|
|
|
|
|
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; //ÿɾ<C3BF><C9BE>һ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>100<30><30>
|
|
|
|
|
if( del_rows>0 && ( tetris->score%1000==0 || tetris->score/1000>tetris->level-1 ) )
|
|
|
|
|
{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1000<30>ּ<EFBFBD><D6BC>ۼ<EFBFBD>ɾ<EFBFBD><C9BE>10<31>У<EFBFBD><D0A3>ٶȼӿ<C8BC>20ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
tetris->speed-=20;
|
|
|
|
|
tetris->level++;
|
|
|
|
|
}
|
|
|
|
|
if(tetris->speed==0)
|
|
|
|
|
{
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(17,18);
|
|
|
|
|
color(14);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(32,20);
|
|
|
|
|
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1/2<><32><EFBFBD><EFBFBD>");
|
|
|
|
|
color(11);
|
|
|
|
|
scanf("%d", &n); //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>2
|
|
|
|
|
switch (n) //<2F><>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
system("cls");
|
|
|
|
|
Replay(tetris); //<2F><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void Flag(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>
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
*/
|
|
|
|
|
void Gameplay()
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
struct Tetris t,*tetris=&t; //<2F><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD>벢ָ<EBB2A2><D6B8><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char ch; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
tetris->number=0; //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30>
|
|
|
|
|
tetris->speed=300; //<2F><>ʼ<EFBFBD>ƶ<EFBFBD><C6B6>ٶ<EFBFBD>Ϊ300ms
|
|
|
|
|
tetris->score=0; //<2F><>ʼ<EFBFBD><CABC>Ϸ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>Ϊ0<CEAA><30>
|
|
|
|
|
tetris->level=1; //<2F><>ʼ<EFBFBD><CABC>ϷΪ<CFB7><CEAA>1<EFBFBD><31>
|
|
|
|
|
while(1) //ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬ֱ<E9A3AC><D6B1><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Flag(tetris); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Temp=tetris->flag; //<2F><>ס<EFBFBD><D7A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
tetris->x=FrameX+2*Frame_width+6; //<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>淽<EFBFBD><E6B7BD><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
|
|
|
|
tetris->y=FrameY+10; //<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>淽<EFBFBD><E6B7BD><EFBFBD><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
|
|
|
|
|
tetris->flag = tetris->next; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
PrintTetris(tetris); //<2F><><EFBFBD>ô<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD>鷽<EFBFBD><E9B7BD>
|
|
|
|
|
tetris->x=FrameX+Frame_width; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
|
|
|
|
tetris->y=FrameY-1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
|
|
|
|
|
tetris->flag=Temp;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
while(1) //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7>鷽<EFBFBD><E9B7BD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>鲻<EFBFBD><E9B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
label:PrintTetris(tetris); //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
Sleep(tetris->speed); //<2F>ӻ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
CleanTetris(tetris); //<2F><><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
|
|
|
|
|
Temp1=tetris->x; //<2F><>ס<EFBFBD><D7A1><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
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><> <20><><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><> <20><><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==72) //<2F><> <20><><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<=11 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
tetris->flag++;
|
|
|
|
|
tetris->flag%=4;
|
|
|
|
|
tetris->flag+=8;
|
|
|
|
|
}
|
|
|
|
|
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>ͣ
|
|
|
|
|
{
|
|
|
|
|
PrintTetris(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 label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ch == 27)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
memset(a,0,6400*sizeof(int)); //<2F><>ʼ<EFBFBD><CABC>a<EFBFBD><61><EFBFBD><EFBFBD>
|
|
|
|
|
title();
|
|
|
|
|
welcom();
|
|
|
|
|
}
|
|
|
|
|
if(ifMove(tetris)==0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
{
|
|
|
|
|
tetris->x=Temp1;
|
|
|
|
|
tetris->flag=Temp2;
|
|
|
|
|
}
|
|
|
|
|
else //<2F><><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>ִ<EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
goto label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tetris->y++; //<2F><><EFBFBD><EFBFBD>û<EFBFBD>в<EFBFBD><D0B2><EFBFBD>ָ<EFBFBD><EFBFBD><EEA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
if(ifMove(tetris)==0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>Ҳ<EFBFBD><D2B2>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ˴<DAB4>
|
|
|
|
|
{
|
|
|
|
|
tetris->y--;
|
|
|
|
|
PrintTetris(tetris);
|
|
|
|
|
Del_Fullline(tetris);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鴥<EFBFBD><E9B4A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
for(i=tetris->y-2;i<tetris->y+2;i++)
|
|
|
|
|
{
|
|
|
|
|
if(i==FrameY)
|
|
|
|
|
{
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
gotoxy(17,18);
|
|
|
|
|
color(14);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>-------1");
|
|
|
|
|
gotoxy(44,18);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>-------2\n");
|
|
|
|
|
int n;
|
|
|
|
|
gotoxy(32,20);
|
|
|
|
|
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1/2<><32><EFBFBD><EFBFBD>");
|
|
|
|
|
color(11);
|
|
|
|
|
scanf("%d", &n); //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>2
|
|
|
|
|
switch (n) //<2F><>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
system("cls");
|
|
|
|
|
Replay(tetris); //<2F><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tetris->flag = tetris->next; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>(<28>ұߴ<D2B1><DFB4><EFBFBD>)
|
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
|
CleanTetris(tetris);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
*/
|
|
|
|
|
void Replay(struct Tetris *tetris)
|
|
|
|
|
{
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
memset(a,0,6400*sizeof(int)); //<2F><>ʼ<EFBFBD><CABC>a<EFBFBD><61><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><F2B2BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸֱ<CFB7>ӽ<EFBFBD><D3BD><EFBFBD>
|
|
|
|
|
DrwaGameframe(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
Gameplay(); //<2F><>ʼ<EFBFBD><CABC>Ϸ
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void explation()
|
|
|
|
|
{
|
|
|
|
|
int i,j = 1;
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
color(13); //<2F><>ɫ
|
|
|
|
|
gotoxy(32,3); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>");
|
|
|
|
|
color(2);
|
|
|
|
|
for (i = 6; i <= 16; i++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±߿<C2B1>===
|
|
|
|
|
{
|
|
|
|
|
for (j = 15; j <= 60; j++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ߿<D2B1>||
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j, i);
|
|
|
|
|
if (i == 6 || i == 16) printf("=");
|
|
|
|
|
else if (j == 15 || j == 59) printf("||");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
color(3);
|
|
|
|
|
gotoxy(18,7);
|
|
|
|
|
printf("tip1: <20><><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD>ͨ<EFBFBD><CDA8> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
color(10);
|
|
|
|
|
gotoxy(18,9);
|
|
|
|
|
printf("tip2: ͨ<><CDA8> <20><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת");
|
|
|
|
|
color(14);
|
|
|
|
|
gotoxy(18,11);
|
|
|
|
|
printf("tip3: <20><><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>Ϸ<EFBFBD><CFB7><EFBFBD>ٰ<EFBFBD><D9B0>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
color(4);
|
|
|
|
|
gotoxy(18,13);
|
|
|
|
|
printf("tip4: <20><>ESC<53>˳<EFBFBD><CBB3><EFBFBD>Ϸ");
|
|
|
|
|
getch(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
system("cls"); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
main(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void regulation()
|
|
|
|
|
{
|
|
|
|
|
int i,j = 1;
|
|
|
|
|
system("cls");
|
|
|
|
|
color(13);
|
|
|
|
|
gotoxy(34,3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
color(2);
|
|
|
|
|
for (i = 6; i <= 18; i++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±߿<C2B1>===
|
|
|
|
|
{
|
|
|
|
|
for (j = 12; j <= 70; j++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ߿<D2B1>||
|
|
|
|
|
{
|
|
|
|
|
gotoxy(j, i);
|
|
|
|
|
if (i == 6 || i == 18) printf("=");
|
|
|
|
|
else if (j == 12 || j == 69) printf("||");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
color(12);
|
|
|
|
|
gotoxy(16,7);
|
|
|
|
|
printf("tip1: <20><>ͬ<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(22,9);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>úͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ײ<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
gotoxy(22,11);
|
|
|
|
|
printf("һ<EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
color(14);
|
|
|
|
|
gotoxy(16,13);
|
|
|
|
|
printf("tip2: ÿ<><C3BF><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100");
|
|
|
|
|
color(11);
|
|
|
|
|
gotoxy(16,15);
|
|
|
|
|
printf("tip3: ÿ<>ۼ<EFBFBD>1000<30>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ȼ<EFBFBD>");
|
|
|
|
|
color(10);
|
|
|
|
|
gotoxy(16,17);
|
|
|
|
|
printf("tip4: <20><><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");
|
|
|
|
|
welcom();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>˳<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void close()
|
|
|
|
|
{
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
int main(){
|
|
|
|
|
title();
|
|
|
|
|
welcom();
|
|
|
|
|
}
|
|
|
|
|
|