#include<stdio.h>
#include<windows.h>//字体颜色,窗口
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#include <mmsystem.h>
#pragma comment(lib,“winmm.lib”)

#define zuobiaox 13 //游戏窗口左上角的x轴坐标
#define zuobiaoy 3 //游戏窗口左上角y轴的坐标
#define height 20 //游戏窗口的高度
#define width 20 //游戏窗口的宽度

int i, j, Temp, Temp1, Temp2;
int a[80][80] = { 0 }; //标记游戏屏幕的图案:2表示游戏边框,1表示方块,0表无图案
int b[4];//标记4个口方块,0表示没有方块1表示有方块
struct fangkuai
{
int x;
int y;
int flag;
int next;
int speed;
int number;
int score;
int level;

};
HANDLE hOUT;//控制台句柄

int color(int c);//控制台中的文字颜色
void gotoxy(int x, int y);//光标移动到指定位置
void drwa();//绘制游戏边框
void falg(struct fangkuai *);//随机产生方块类型的序号
void makefangkuai(struct fangkuai *);//绘制俄罗斯方块
void printffangkuai(struct fangkuai *);//打印俄罗斯方块
void clean(struct fangkuai *);//清楚方块的痕迹
int ifmove(struct fangkuai *);//判断是否能移动,返回值为1能移动
void del(struct fangkuai *);//满行删减
void gameplay();
void regulation();//游戏规则
void explation();//按键说明
void welcome();//欢迎界面
void replay(struct fangkuai *);//重新开始
void title();//欢迎界面上方的标题
void flower();//装饰
void close();//关闭游戏

//获取光标的位置
void gotoxy(int x, int y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}

//控制文字颜色
int color(int c)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
return 0;

}

//制作游戏窗口
void drwa()
{
gotoxy(zuobiaox + width - 7, zuobiaoy - 2);
color(11);
printf(“Welcome to the game!”);
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 8);
color(2);
printf("***************************");
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 7);
color(3);
printf("下一出现方块: “);
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 13);
color(2);
printf(”**************************");
gotoxy(zuobiaox + 2 * width + 3, zuobiaox + 17);
color(14);
printf(“↑键:旋转”);
gotoxy(zuobiaox + 2 * width + 3, zuobiaox + 19);
printf(“空格:暂停游戏”);
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 15);
printf(“Esc:退出游戏”);
gotoxy(zuobiaox, zuobiaoy);
color(12);
printf(“╔”);
gotoxy(zuobiaox + 2 * width - 2, zuobiaoy);
printf(“╗”);
gotoxy(zuobiaox, zuobiaoy + height);
printf(“╚”);
gotoxy(zuobiaox + 2 * width - 2, zuobiaoy + height);
printf(“╝”);
a[zuobiaox][zuobiaoy + height] = 2;//记住该处已有的图案
a[zuobiaox + 2 * width - 2][zuobiaoy + height] = 2;
for (i = 2; i < 2 * width; i += 2)
{
gotoxy(zuobiaox + i, zuobiaoy);
printf(“═”);//打印横框
}
for (i = 2; i < 2 * width - 2; i += 2)
{
gotoxy(zuobiaox + i, zuobiaoy + height);
printf(“═”);//打印下横框
a[zuobiaox + i][ zuobiaoy + height] = 2;
}
for (i = 1; i < height; i++)
{
gotoxy(zuobiaox, zuobiaoy + i);
printf(“║”);//打印左竖框
a[zuobiaox][zuobiaoy + i] = 2;//记住左竖框有图案
}
for (i = 1; i < height; i++)
{
gotoxy(zuobiaox + 2 * width - 2, zuobiaoy + i);
printf(“║”);//打印左竖框
a[zuobiaox+2width-2][zuobiaoy + i] = 2;//记住左竖框有图案
}
}

void makefangkuai(struct fangkuai Fangkuai)
{
a[Fangkuai->x][Fangkuai->y] = b[0];//中心方块位置的图形状态
switch (Fangkuai->flag)//共七大类,19种类型
{
case 1: //田字方块
{
color(10);
a[Fangkuai->x][Fangkuai->y - 1] = b[1];
a[Fangkuai->x + 2][Fangkuai->y-1]=b[2];
a[Fangkuai->x + 2][Fangkuai->y] = b[3];
break;
}
case 2://直线方块■■■
{
color(13);
a[Fangkuai->x - 2][Fangkuai->y] = b[1];
a[Fangkuai->x + 2][Fangkuai->y] = b[2];
a[Fangkuai->x + 4][Fangkuai->y] = b[3];
break;
}
case 3://直线方块
/ ■

■*/
{ color(13); a[Fangkuai->x][Fangkuai->y - 1] = b[1];
a[Fangkuai->x][Fangkuai->y - 2] = b[2]; a[Fangkuai->x][Fangkuai->y + 1] = b[3];
break; } case 4://T字方块 /* ■■■ ■ */ { color(11); a[Fangkuai->x - 2][Fangkuai->y]
= b[1]; a[Fangkuai->x + 2][Fangkuai->y] = b[2]; a[Fangkuai->x][Fangkuai->y + 1]
= b[3]; break; } case 5://顺时针90°T字方块 /* ■ ■■ ■ */ { color(11);
a[Fangkuai->x][Fangkuai->y - 1] = b[1]; a[Fangkuai->x][Fangkuai->y + 1] = b[2];
a[Fangkuai->x - 2][Fangkuai->y] = b[3]; break; } case 6: /* ■ ■■■ */ {
color(11); a[Fangkuai->x][Fangkuai->y - 1] = b[1]; a[Fangkuai->x -
2][Fangkuai->y] = b[2]; a[Fangkuai->x + 2][Fangkuai->y] = b[3]; break; } case
7://顺时针270T字方块 /* ■ ■■ ■ */ { color(11); a[Fangkuai->x][Fangkuai->y - 1] =
b[1]; a[Fangkuai->x][Fangkuai->y + 1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y] =
b[3]; break; } case 8:/* ■■ ■■ */ { color(14); a[Fangkuai->x][Fangkuai->y + 1]
= b[1]; a[Fangkuai->x - 2][Fangkuai->y] = b[2]; a[Fangkuai->x + 2][Fangkuai->y
+ 1] = b[3]; break; } case 9:/*顺时针Z字方块 ■ ■■ ■ */ { color(14);
a[Fangkuai->x][Fangkuai->y - 1] = b[1]; a[Fangkuai->x - 2][Fangkuai->y] = b[2];
a[Fangkuai->x - 2][Fangkuai->y + 1] = b[3]; break; } case 10:/*反转Z字方块 ■■ ■■ */
{ color(14); a[Fangkuai->x][Fangkuai->y - 1] = b[1]; a[Fangkuai->x -
2][Fangkuai->y - 1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y] = b[3]; break; }
case 11:/*顺时针Z字方块 ■ ■■ ■ */ { color(14); a[Fangkuai->x][Fangkuai->y + 1] =
b[1]; a[Fangkuai->x - 2][Fangkuai->y - 1] = b[2]; a[Fangkuai->x -
2][Fangkuai->y] = b[3]; break; } case 12:/*7字方块 ■■ ■ ■ */ { color(12);
a[Fangkuai->x][Fangkuai->y - 1] = b[1]; a[Fangkuai->x][Fangkuai->y + 1] = b[2];
a[Fangkuai->x - 2][Fangkuai->y - 1] = b[3]; break; } case 13:/*顺时针90°7字方块 ■ ■■■
*/ { color(12); a[Fangkuai->x - 2][Fangkuai->y] = b[1]; a[Fangkuai->x +
2][Fangkuai->y - 1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y] = b[3]; break; }
case 14:/* 顺时针180°7字方块 ■ ■ ■■ */ { color(12); a[Fangkuai->x][Fangkuai->y - 1] =
b[1]; a[Fangkuai->x][Fangkuai->y + 1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y +
1] = b[3]; break; } case 15:/* ■■■ ■ */ { color(12); a[Fangkuai->x -
2][Fangkuai->y] = b[1]; a[Fangkuai->x - 2][Fangkuai->y + 1] = b[2];
a[Fangkuai->x + 2][Fangkuai->y] = b[3]; break; } case 16:/* ■■ ■ ■ */ {
color(12); a[Fangkuai->x][Fangkuai->y + 1] = b[1]; a[Fangkuai->x][Fangkuai->y -
1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y - 1] = b[3]; break; } case 17:/* ■■■
■ */ { color(12); a[Fangkuai->x - 2][Fangkuai->y] = b[1]; a[Fangkuai->x +
2][Fangkuai->y + 1] = b[2]; a[Fangkuai->x + 2][Fangkuai->y] = b[3]; break; }
case 18:/* ■ ■ ■■ */ { color(12); a[Fangkuai->x][Fangkuai->y - 1] = b[1];
a[Fangkuai->x][Fangkuai->y + 1] = b[2]; a[Fangkuai->x - 2][Fangkuai->y + 1] =
b[3]; break; } case 19:/* ■ ■■■ */ { color(12); a[Fangkuai->x - 2][Fangkuai->y]
= b[1]; a[Fangkuai->x - 2][Fangkuai->y - 1] = b[2]; a[Fangkuai->x +
2][Fangkuai->y] = b[3]; } }
}

/打印俄罗斯方块/
void printffangkuai(struct fangkuai *Fangkuai)
{
for (i = 0; i < 4; i++)
{
b[i] = 1;//数组b[4]的每个元素的值都是1
}
makefangkuai(Fangkuai);
for (i = Fangkuai->x - 2; i <= Fangkuai->x + 4; i += 2)
{
for (j = Fangkuai->y - 2; j <= Fangkuai->y + 1; j++)
{
if (a[i][j] == 1 && j > zuobiaoy)//j>zuobiaoy是框定图案在框中才有
{
gotoxy(i, j);
printf(“■”);
}
}
}
//打印菜单信息
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 1);
color(4);
printf(“level:”);
color(12);
printf("%d", Fangkuai->level);
gotoxy(zuobiaoy + 2 * width + 13, zuobiaoy + 3);
color(4);
printf(“score:”);
color(12);
printf("%d", Fangkuai->score);
gotoxy(zuobiaox + 2 * width + 3, zuobiaoy + 5);
color(4);
printf(“speed:”);
color(12);
printf("%d", Fangkuai->speed);

}

/判断是否可移动/
int ifmove(struct fangkuai* Fangkuai)
{
if (a[Fangkuai->x][Fangkuai->y] != 0) //当中心方块位置上有图案时,返回值为0,既不可移动
{
return 0;
}
else
{//当为田字方块且中心方块位置外,其他■字方块位置上无图案时,说明这个位置能够放下田字方块,可以移动到这个位置,返回值为1,即可移动
//比如田字方块,它的中心方块时左下角的■,如果它的上,右,右上的位置为空,则这个位置就可以放一个田字方块;如果有一个位置上不为空,都放不下一个田
if ((Fangkuai->flag == 1 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x + 2][Fangkuai->y - 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 2 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x + 2][Fangkuai->y] == 0 && a[Fangkuai->x + 4][Fangkuai->y] == 0))
|| (Fangkuai->flag == 3 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y - 2] == 0 && a[Fangkuai->x][Fangkuai->y + 1] == 0))
|| (Fangkuai->flag == 4 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x + 2][Fangkuai->y] == 0 && a[Fangkuai->x][Fangkuai->y + 1] == 0))
|| (Fangkuai->flag == 5 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y + 1] == 0 && a[Fangkuai->x - 2][Fangkuai->y] == 0))
|| (Fangkuai->flag == 6 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y] == 0 && a[Fangkuai->x - 2][Fangkuai->y] == 0))
|| (Fangkuai->flag == 7 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y + 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] == 0))
|| (Fangkuai->flag == 8 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y] == 0 && a[Fangkuai->x + 2][Fangkuai->y + 1] ==
0)) || (Fangkuai->flag == 9 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y] == 0 && a[Fangkuai->x - 2][Fangkuai->y + 1] ==
0)) || (Fangkuai->flag == 10 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y - 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 11 && (a[Fangkuai->x][Fangkuai->y + 1] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y - 1] == 0 && a[Fangkuai->x - 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 12 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y + 1] == 0 && a[Fangkuai->x - 2][Fangkuai->y - 1] ==
0)) || (Fangkuai->flag == 13 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x + 2][Fangkuai->y - 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 14 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y + 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y + 1] ==
0)) || (Fangkuai->flag == 15 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y + 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 16 && (a[Fangkuai->x][Fangkuai->y + 1] == 0 &&
a[Fangkuai->x][Fangkuai->y - 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y - 1] ==
0)) || (Fangkuai->flag == 17 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x + 2][Fangkuai->y + 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0)) || (Fangkuai->flag == 18 && (a[Fangkuai->x][Fangkuai->y - 1] == 0 &&
a[Fangkuai->x][Fangkuai->y + 1] == 0 && a[Fangkuai->x - 2][Fangkuai->y + 1] ==
0)) || (Fangkuai->flag == 19 && (a[Fangkuai->x - 2][Fangkuai->y] == 0 &&
a[Fangkuai->x - 2][Fangkuai->y - 1] == 0 && a[Fangkuai->x + 2][Fangkuai->y] ==
0))) { return 1; } } return 0;
}

/随机产生俄罗斯方块类型的序号/
void flag(struct fangkuai *Fangkuai)
{
Fangkuai->number++;//记住产生方块的个数
srand(time(NULL));
if (Fangkuai->number == 1)
{
Fangkuai->flag = rand() % 19 + 1;//记住第一个方块的序号
}
Fangkuai->next = rand() % 19 + 1;//记住下一个方块的序号
}

/清除痕迹/
void clean(struct fangkuai *Fangkuai)
{
for (i = 0; i < 4; i++)
b[i] = 0;//数组b[4]的每个元素的值都为0
makefangkuai(Fangkuai);
for (i = Fangkuai->x - 2; i <= Fangkuai->x + 4; i += 2)
{
for (j = Fangkuai->y - 2; j <= Fangkuai->y + 1; j++)
{
if (a[i][j] == 0 && j > zuobiaoy)
{
gotoxy(i, j);
printf(" “);
}
}
}
}
/判断是否满行并删减/
void del(struct fangkuai *Fangkuai)//当某行有width-2个方块时,则满行消除
{
int k=0, Del = 0;//分别用于记录某行方块的个数和删除方块的行数的变量
for (j = zuobiaoy + height ; j >= zuobiaoy + 1; j–)
{
for (i = zuobiaox + 2; i < zuobiaox + 2 * width - 2; i += 2)
{
if (a[i][j] == 1)//竖坐标依次从下往上,横坐标依次由左至右判断是否满行
{
k++;//记录此行方块的个数
if (k == width - 2)//如果满行
{
for (k = zuobiaox + 2; k < zuobiaox + 2 * width - 2; k += 2)//删除满行的方块
{
a[k][j] = 0;
gotoxy(k, j);
printf(” “);
}
for (k = j - 1; k > zuobiaoy; k–)//如果删除行以上的位置有方块,则先清除,再将方块下移一个位置
{
for (i = zuobiaox + 2; i < zuobiaox + 2 * 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(“■”);
}
}
}
j++;//方块下移后,重新判断删除行是否满行
Del++;//记录删除方块的行数
}
}
}
}
Fangkuai->score += 100 * Del;//没删除一行,得100分
if (Del > 0 && (Fangkuai->score % 200 == 0 || Fangkuai->score / 200 >
Fangkuai->level - 1))
{
Fangkuai->speed -= 20; Fangkuai->level++; }
}

void gameplay()
{
int n;
struct fangkuai t, *Fangkuai = &t;//定义结构体的指针并指向结构体变量
char ch;//接受键盘输入的变量
Fangkuai->number = 0;
Fangkuai->speed = 150;
Fangkuai->score = 0;
Fangkuai->level = 1;
while (1)
{
flag(Fangkuai);//随机方块序号
Temp = Fangkuai->flag;//记住当前方块序号
Fangkuai->x = zuobiaox + 2 * width + 6;//获得预览界面方块的x坐标
Fangkuai->y = zuobiaoy + 10;//获得预览界面方块的y 坐标
Fangkuai->flag = Fangkuai->next;//获得下一个序号
printffangkuai(Fangkuai);
Fangkuai->x = zuobiaox + width;//获得游戏窗口中心方块y的坐标
Fangkuai->y = zuobiaoy - 1;
Fangkuai->flag = Temp;//获得当前的方块序号
while (1)//控制方块方向,直至方块不再下移
{
label:printffangkuai(Fangkuai);//打印方块
Sleep(Fangkuai->speed);
clean(Fangkuai);
Temp1 = Fangkuai->x;//记住当前中心方块横坐标的值
Temp2 = Fangkuai->flag;//记住当前方块的序号
if (kbhit())
{
ch = getch();
if (ch == 75)//按←向左
{
Fangkuai->x -= 2;
}
if (ch == 77)//→
{
Fangkuai->x += 2;
}
if (ch == 80)//↓加快下落
{
if (ifmove(Fangkuai) != 0)
{
Fangkuai->y += 2;
}
if (ifmove(Fangkuai) == 0)
{
Fangkuai->y = zuobiaoy + height - 2;
}
}
if (ch == 72)//↑变形
{
if (Fangkuai->flag >= 2 && Fangkuai->flag <= 3)
{
Fangkuai->flag++;
Fangkuai->flag %= 2;
Fangkuai->flag += 2;
} if (Fangkuai->flag >= 4 && Fangkuai->flag <= 7) { Fangkuai->flag++;
Fangkuai->flag %= 4; Fangkuai->flag += 4; } if (Fangkuai->flag >= 8 &&
Fangkuai->flag <= 11) { Fangkuai->flag++; Fangkuai->flag %= 4; Fangkuai->flag
+= 8; } if (Fangkuai->flag >= 12 && Fangkuai->flag <= 15) { Fangkuai->flag++;
Fangkuai->flag %= 4; Fangkuai->flag += 12; } if (Fangkuai->flag >= 16 &&
Fangkuai->flag <= 19) { Fangkuai->flag++; Fangkuai->flag %= 4; Fangkuai->flag
+= 16; } } if (ch == 32) //空格暂停 { printffangkuai(Fangkuai); while (1) { if
(kbhit())//再按空格键,继续游戏 { ch = getch(); if (ch == 32) { goto label; } } } } if
(ch == 27) { system("cls"); memset(a, 0, 6400 * sizeof(int));//初始化数组 welcome();
} if (ifmove(Fangkuai) == 0)//如果不可动,上面操作无效 { Fangkuai->x = Temp1;
Fangkuai->flag = Temp2; } else //如果可动,执行操作 goto label; }
Fangkuai->y++;//如果没有操作指令,方块向下 if (ifmove(Fangkuai) == 0)//如果向下移动且不可动,方块放在此处 {
Fangkuai->y--; printffangkuai(Fangkuai); del(Fangkuai); break; } } for (i =
Fangkuai->y - 2; i < Fangkuai->y + 2; i++)//游戏结束条件:方块触到框顶 { if (i == zuobiaoy)
{ system("cls"); gotoxy(29, 7); printf(" \n"); color(12); printf("\t\t\t■■■■ ■
■ ■■ \n"); printf("\t\t\t■ ■■ ■ ■ ■ \n"); printf("\t\t\t■■■ ■ ■ ■ ■ ■\n");
printf("\t\t\t■ ■ ■■ ■ ■ \n"); printf("\t\t\t■■■■ ■ ■ ■■ \n"); gotoxy(17, 18);
color(14); printf("重新玩一把---1"); gotoxy(44, 18); printf("不玩了---2"); int n;
gotoxy(32, 20); printf("选择【1/2】:"); color(11); scanf("%d", &n); switch (n) {
case 1: {system("cls"); replay(Fangkuai); break; } case 2: { exit(0); break; }
} } } Fangkuai->flag = Fangkuai->next;//清除下一个俄罗斯方块的图形 Fangkuai->x = zuobiaox +
2 * width + 6; Fangkuai->y = zuobiaoy + 10; clean(Fangkuai); }
}

void replay(struct fangkuai*)
{
system(“cls”);
memset(a, 0, 6400 * sizeof(int));
drwa();
gameplay();
}

int main()
{
title();
mciSendString(L"open D:\饶品德作品\ConsoleApplication1\aa.mp3", NULL, 0, 0);
mciSendString(L"play D:\饶品德作品\ConsoleApplication1\aa.mp3", NULL, 0, 0);
flower();
welcome();

}

/欢迎界面/
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("||");
} } color(12); gotoxy(25, 12); printf("1.开始游戏"); gotoxy(40, 12);
printf("2.按键说明"); gotoxy(25, 17); printf("3.游戏规则"); gotoxy(40, 17);
printf("4.退出"); gotoxy(21, 22); color(3); printf("请选择[1 2 3 4 ]:[ ]\b\b");
color(14); scanf("%d", &n); switch (n) { case 1: system("cls"); drwa();
gameplay(); break; case 2: explation(); break; case 3: regulation(); break;
case 4: close(); break; }
}

void title()
{
color(15);
gotoxy(16, 3);
printf(“趣 味 俄 罗 斯 方 块\n”);
color(11);
gotoxy(18, 5);
printf(“■”);
gotoxy(18, 6);
printf(“■■”);
gotoxy(18, 7);
printf(“■”);
color(14); gotoxy(26, 6); printf("■■"); gotoxy(28, 7); printf("■■");
color(10); gotoxy(36, 6); printf("■■"); gotoxy(36, 7); printf("■■"); color(13);
gotoxy(45, 5); printf("■"); gotoxy(45, 6); printf("■"); gotoxy(45, 7);
printf("■"); gotoxy(45, 8); printf("■"); color(12); gotoxy(56, 6); printf("■");
gotoxy(52, 7); printf("■■■");
}

void flower()
{
gotoxy(66, 11);
color(12);
printf("()");
gotoxy(64, 12);
printf("()");
gotoxy(66, 13);
printf("()");
gotoxy(67, 12);
color(6);
printf("@");
gotoxy(72, 10);
color(13);
printf("()");
gotoxy(76, 10);
printf("()");
gotoxy(74, 9);
printf("()");
gotoxy(74, 11);
printf("(_)");
gotoxy(75, 10);
color(6);
printf("@");
gotoxy(71, 12);
printf("|");
gotoxy(72, 11);
printf("/");
gotoxy(70, 13);
printf("\|");
gotoxy(70, 14);
printf("~|/");
gotoxy(70, 15);
printf("\|");
gotoxy(71, 16);
printf("|/");
gotoxy(71, 17);
printf("|");
gotoxy(67, 17);
color(10);
printf("///");
gotoxy(73, 17);
printf("//");
gotoxy(67, 18);
color(2);
printf("^^^^^^^");

}

void close()
{
exit(0);
}
void explation()
{
int i, j = 1;
system(“cls”);
color(13);
gotoxy(32, 3);
printf(“按键说明”);
color(2);
for (i = 6; i <= 16; i++)
{
for (j = 15; j <= 60; j++)
{
gotoxy(j, i);
if (i == 6 || i == 16)
printf("=");
else if (j == 15 || j == 59) printf("||");
}
}
color(3);
gotoxy(18, 7);
printf(“玩家可通过←→移动方块”);
color(10);
gotoxy(18, 9);
printf(“↑使方块旋转”);
color(14);
gotoxy(18, 11);
printf(“↓加速下落”);
color(11);
gotoxy(18, 13);
printf(“空格暂停,Esc退出”);
getch();
system(“cls”);
main();
}

void regulation()
{
int i, j = 1;
system(“cls”);
color(13);
gotoxy(34, 3);
printf(“游戏规则”);
color(2);
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(“每消除一行,积分增加100”);
color(11);
gotoxy(16, 15);
printf(“每积累1000分提升一个等级”);
getch();
system(“cls”);
welcome();
}

//注意:
主函数中:
mciSendString(L"open D:\饶品德作品\ConsoleApplication1\aa.mp3", NULL, 0, 0);
mciSendString(L"play D:\饶品德作品\ConsoleApplication1\aa.mp3", NULL, 0, 0);
这两句作用是添加
背景音乐,你需要下载一首歌曲,格式如上代码所示,把歌曲路径放入与代码相同的文件中,aa.mp3就是XXX.mp3,歌曲名字而已,说的不详细,这个可以百度搜。

技术
©2019-2020 Toolsou All rights reserved,
JVM概述VUE+Canvas 实现桌面弹球消砖块小游戏javascript事件(零基础详解)Pikachu漏洞练习平台明解c/c++程序的内存模型--内存四区python实现vlookup_干货一:怎么在python里面实现vlookupswift 5.0 创建一个获取验证码的按钮,实现倒计时效果首期500亿,成立新部门,腾讯准备做什么?关于蓝桥杯大赛,你应该了解的那些事!解决Selenium ActionChains拖动元素无效