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

773 lines
21 KiB

6 years ago
/********ͷ<>ļ<EFBFBD>*********/
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
/********<2A><EFBFBD><EAB6A8>********/
#define FrameX 13
#define FrameY 3
#define Frame_height 20 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>ڸ߶<DAB8>
#define Frame_width 18//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>
/********ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>*********/
int i,j,Temp,Temp1,Temp2;
int a[80][80]={0};//a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2,1,0<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿򣬷<DFBF><F2A3ACB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
int b[4];//ÿ<>ַ<EFBFBD><D6B7><EFBFBD><E9B6BC><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>b<EFBFBD><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ͼ<EFBFBD><CDBC>
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><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
int speed;//<2F><><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
int number;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
int score;//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
int level;//<2F><>Ϸ<EFBFBD>ȼ<EFBFBD>
};
HANDLE hOut;//<2F><><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
/******<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*******/
int color(int c);
static void gotoxy(int x, int y);//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
void DrawGameframe(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>߿<EFBFBD>
void Flag(struct Tetris * );//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><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><DCB7>ƶ<EFBFBD>
void Del_Fullline(struct Tetris *);//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
void GamePlay();//<2F><>ʼ<EFBFBD><CABC>Ϸ
void regulation();//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
void explation();//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
void welcome();//<2F><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD>
void Replay(struct Tetris *);//<2F><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC>Ϸ
void title();//<2F><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD>
void close();//<2F>ر<EFBFBD><D8B1><EFBFBD>Ϸ
/*****<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>******/
int color(int c){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
return 0;
}
/*****<2A><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>*******/
static void gotoxy(int x, int y){
COORD point = { x, y };//<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>õ<EFBFBD>λ<EFBFBD><CEBB>x,y
HANDLE HOutput = GetStdHandle(STD_OUTPUT_HANDLE);//ʹ<><CAB9>GetStdHandle(STD_OUTPUT_HANDLE)<29><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
SetConsoleCursorPosition(HOutput, point);//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>λ<EFBFBD><CEBB>
}
/*****<2A><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>********/
void title(){
color(15);
gotoxy(30,3);
printf("Ȥζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
//<2F><><EFBFBD><EFBFBD>
color(11);
gotoxy(18,5);
printf("<EFBFBD><EFBFBD>");
gotoxy(18,6);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
gotoxy(18,7);
printf("<EFBFBD><EFBFBD>");
//T<>ַ<EFBFBD><D6B7><EFBFBD>
color(14);
gotoxy(26,6);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
gotoxy(28,7);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
//Z<>ַ<EFBFBD><D6B7><EFBFBD>
color(10);
gotoxy(36,6);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
gotoxy(36,7);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
//<2F><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
color(13);
gotoxy(45,5);
printf("<EFBFBD><EFBFBD>");
gotoxy(45,6);
printf("<EFBFBD><EFBFBD>");
gotoxy(45,7);
printf("<EFBFBD><EFBFBD>");
gotoxy(45,8);
printf("<EFBFBD><EFBFBD>");
//ֱ<>߷<EFBFBD><DFB7><EFBFBD>
color(12);
gotoxy(56,6);
printf("<EFBFBD><EFBFBD>");
gotoxy(52,7);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
//7<>ַ<EFBFBD><D6B7><EFBFBD>
}
/*******<2A>˵<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>߿<EFBFBD>*******/
void welcome()
{
int n;
int i,j=1;
color(14);
for(i=9;i<=20;i++){
for(j=15;j<=60;j++){
gotoxy(j,i);
if(i==9||i==20) printf("=");
else if(j==15||j==59) printf("::");
}
}
/*******<2A>˵<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>********/
color(12);
gotoxy(25,12);
printf("1.<2E><>ʼ<EFBFBD><CABC>Ϸ");
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);
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>[1,2,3,4]:[ ]\b\b");
scanf("%d",&n);
switch(n){
case 1:
system("cls");
DrawGameframe();
6 years ago
Gameplay();
6 years ago
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
}
/*******<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>*******/
void DrawGameframe()
{
/***********<2A><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>***********/
gotoxy(FrameX+Frame_width-7,FrameY-2);
color(11);
printf("Ȥζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
/**********<2A><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>********/
gotoxy(FrameX+2*Frame_width+3,FrameY+7);
color(2);
printf("**********");
gotoxy(FrameX+2*Frame_width+13,FrameY+7);
color(3);
printf("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>");
gotoxy(FrameX+2*Frame_width+3,FrameY+13);
color(2);
printf("**********");
/**********<2A><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>***********/
gotoxy(FrameX+2*Frame_width+3,FrameY+17);
color(14);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ת");
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>Ϸ");
/*********<2A><>Ϸ<EFBFBD>߿<EFBFBD>***********/
gotoxy(FrameX,FrameY);
color(12);
printf("<EFBFBD>X");
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;
a[FrameX+2*Frame_width-2][FrameY+Frame_height]=2;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=2;i<2*Frame_width-2;i+=2){
gotoxy(FrameX+i,FrameY);
printf("<EFBFBD>T");
}
6 years ago
for(i=2;i<2*Frame_width-2;i+=2){
6 years ago
gotoxy(FrameX+i,FrameY+Frame_height);
printf("<EFBFBD>T");
a[FrameX+i][FrameY+Frame_height]=2;
}
for(i=1;i<Frame_height;i++){
gotoxy(FrameX,FrameY+i);
printf("<EFBFBD>U");
a[FrameX][FrameY+i]=2;
}
for(i=1;i<Frame_height;i++){
gotoxy(FrameX+2*Frame_width-2,FrameY+i);
printf("<EFBFBD>U");
a[FrameX+2*Frame_width-2][FrameY+i]=2;
}
}
6 years ago
/**
* <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> */
{
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: /*ֱ<>߷<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+1]=b[2];
a[tetris->x][tetris->y+2]=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;
}
}
6 years ago
}
/******<2A><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>*******/
6 years ago
void PrintTetris(struct Tetris *tetris){
6 years ago
for(i=0;i<4;i++) b[i]=1;
MakeTetris(tetris);
for(i=tetris->x-2;i<=tetris->x+4;i+=2){
for(j=tetris->y-1;j<=tetris->y+1;j++){
if(a[i][j]==1&&j>FrameY){
gotoxy(i,j);
printf("<EFBFBD><EFBFBD>");
}
}
}
//<2F><>ӡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ
gotoxy(FrameX+2*Frame_width+3,FrameY+1);
color(4);
printf("level:");
color(12);
printf("%d",tetris->level);
gotoxy(FrameX+2*Frame_width+3,FrameY+3);
color(4);
printf("score:");
color(12);
printf("%d",tetris->score);
gotoxy(FrameX+2*Frame_width+3,FrameY+3);
color(4);
printf("speed");
color(12);
printf("%dms",tetris->speed);
}
6 years ago
/**
* <EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
*/
6 years ago
int ifMove(struct Tetris *tetris)
{
6 years ago
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;
}
6 years ago
}
6 years ago
return 0;
}
6 years ago
6 years ago
void CleanTetris(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
}
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><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>
}
}
}
}
6 years ago
6 years ago
/**
* <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 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++;
}
6 years ago
}
/******<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>*******/
void Flag(struct Tetris *tetris){
tetris->number++;
srand(time(NULL));
if(tetris->number==1){
tetris->flag=rand()%19+1;
}
tetris->next=rand()%19+1;
}
6 years ago
/**
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ϸ
*/
void Gameplay()
{
6 years ago
int n;
6 years ago
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==80) //<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
if(ifMove(tetris)!=0)
{
tetris->y+=2;
6 years ago
}
6 years ago
if(ifMove(tetris)==0)
{
tetris->y=FrameY+Frame_height-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)
{
6 years ago
system("cls");
6 years ago
memset(a,0,6400*sizeof(int));
title(); //<2F><>ʼ<EFBFBD><CABC>a<EFBFBD><61><EFBFBD><EFBFBD>
6 years ago
welcome();
}
6 years ago
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(29,7); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
printf(" \n");
color(12); //<2F><>ɫ
printf("\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><> <20><> <20><><EFBFBD><EFBFBD> \n");
printf("\t\t\t<EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <20><> <20><> <20><> \n");
printf("\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><> <20><> <20><> <20><> <20><> \n");
printf("\t\t\t<EFBFBD><EFBFBD> <09><> <20><> <20><> <20><> <20><> \n");
printf("\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><> <20><> <20><><EFBFBD><EFBFBD> \n");
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);
}
}
/*******<2A><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>*******/
void Replay(struct Tetris *tetris){
system("cls");
memset(a,0,6400*sizeof(int));
DrawGameframe();
Gameplay();
6 years ago
}
6 years ago
/*******<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*******/
int main(){
title();
welcome();
return 0;
}