#include <conio.h>
#include <stdlib.h>
#include<stdio.h>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib") //播放背景音乐的头文件
#include "colorConsole.h"
#include<time.h>
#define SQUARE_COLOR BACKGROUD_RED|BACKGROUD_GREEN //背景颜色
#define SQUARE_COLOR FOREGROUND_BLUE //方块的颜色
#define up 72
#define down 80
#define left 75
#define right 77
#define esc 27
#define MAPW 15 //地图的宽度
#define MAPH 25 //地图的高度
void initiate1();
int * build(); //创建方块 //初始化工作
BOOL isavailable(int a[],int x,int y,int w,int h); //判定是否能放下
void drawblocks(int a[],int w,int h,int x,int y,WORD wColors[],int nColors);
void delete_cache(); //清除键盘缓冲区
void revolve(int a[][4],int w,int h,int *x,int y); //转动方块
void pro();
void end();
void delete_blocks(int *a,int w,int h,int x,int y);
void gameover();
void deletefull_line(int m[][MAPW],int row,int w,int h); //消除一行
int dx=10,dy=5; //屏幕上的偏移量
int score=0,level=0;
int map[MAPH][MAPW];
int a1[4][4]={{1},{1,1,1}};
int a2[4][4]={{0,1},{1,1,1}};
int a3[4][4]={{1,1},{0,1,1}};
int a4[4][4]={{0,0,1},{1,1,1}};
int a5[4][4]={{0,1,1},{1,1}};
int a6[4][4]={{1,1,1,1}};
int a7[4][4]={{1,1},{1,1}};
int a8[4][4]={{0,1},{1,1,1},{0,1}};
int a9[4][4]={{0,1,1,1},{0,1,0,1}};
int a[4][4];
int main()
{
int sign,blank,x,y;
int *b=NULL;
HANDLE handle;
handle=initiate();
WORD wColors[1]={FOREGROUND_BLUE| FOREGROUND_GREEN|FOREGROUND_INTENSITY };
PlaySound(TEXT("E:\\Microsoft Visual Studio\\MyProjects\\为我亲爱的\\转角遇到爱 - 问候歌.wav"),NULL,SND_FILENAME|SND_ASYNC|SND_LOOP);//用异步方式播放音乐,PlaySound函数在开始播放后立即返回
system("CLS");
textout(handle,15,6,wColors+2,1," 游戏说明 :");
textout(handle,22,8,wColors+2,1,"1.键盘上的方向键进行左 右 下的控制");
textout(handle,22,10,wColors+2,1,"2.向上的键,可以让方块旋转");
textout(handle,22,12,wColors+2,1,"3.按 空格键暂停");
textout(handle,26,17,wColors+2,1,"15秒后,自动进入游戏界面");
Sleep(15000);
system("CLS");
while(1)
{
system("CLS");
int n=0;
textout(handle,48,12,wColors+2,1," ☆☆ ☆☆ ☆☆ ☆☆");
textout(handle,48,13,wColors+2,1," ★★ ★ ★★");
textout(handle,48,14,wColors+2,1," ☆☆ 祝你快乐! ☆☆");
textout(handle,48,15,wColors+2,1," ★★ ★★");
textout(handle,48,16,wColors+2,1," ☆☆ ☆☆");
textout(handle,48,17,wColors+2,1," ★★ ★★");
textout(handle,48,18,wColors+2,1," ☆☆ ☆☆");
textout(handle,48,19,wColors+2,1," ★★ ★★");
textout(handle,48,20,wColors+2,1," ☆☆");
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<" 欢迎进入俄罗斯方块 ★☆小跃版 "<<endl;
cout<<endl;
cout<<" 1. Start "<<endl;
cout<<endl;
cout<<" 2. Exit "<<endl;
cout<<" 请输入1或者2,选择开始或者退出游戏 "<<endl;
cout<<" 输入完毕后,请按Enter键进行确认 "<<endl;
cout<<" 请选择 "<<endl;
textout(handle,58,23,wColors+2,1," 心灵所有:卫理");
cin>>n;
switch(n)
{
case 1:
system("CLS");
textout(handle,12,6,wColors+2,1,"请选择游戏等级:");
textout(handle,22,8,wColors+2,1,"1.初级");
textout(handle,22,10,wColors+2,1,"2.中级");
textout(handle,22,12,wColors+2,1,"3.高级");
while(1)
{
char choice;
textout(handle,36,11,wColors+2,1," ......");
textout(handle,36,12,wColors+2,1," _.'__ `. ");
textout(handle,36,13,wColors+2,1," .--(#)(##)---*#*");
textout(handle,36,14,wColors+2,1," .' @ *###*");
textout(handle,36,15,wColors+2,1," : , #####");
textout(handle,36,16,wColors+2,1," `-..__.-' _.-*###*");
textout(handle,36,17,wColors+2,1," `;_: `# ");
textout(handle,36,18,wColors+2,1," ☆ ▽ ");
textout(handle,36,19,wColors+2,1," □ 小 ,□" );
textout(handle,36,20,wColors+2,1," ◇◇ 跃 ◇◇ ");
textout(handle,36,21,wColors+2,1," `-._______.-'");
textout(handle,36,22,wColors+2,1," (______|______)");
choice=_getch();
textout(handle,12,6,wColors+2,1," ");Sleep(200);
textout(handle,22,8,wColors+2,1," ");Sleep(200);
textout(handle,22,10,wColors+2,1," ");Sleep(200);
textout(handle,22,12,wColors+2,1," ");Sleep(200);
textout(handle,36,11,wColors+2,1," ");
textout(handle,36,12,wColors+2,1," ");
textout(handle,36,13,wColors+2,1," ");
textout(handle,36,14,wColors+2,1," ");
textout(handle,36,15,wColors+2,1," ");
textout(handle,36,16,wColors+2,1," ");
textout(handle,36,17,wColors+2,1," ");
textout(handle,36,18,wColors+2,1," ");
textout(handle,36,19,wColors+2,1," ");
textout(handle,36,20,wColors+2,1," ");
textout(handle,36,21,wColors+2,1," ");
textout(handle,36,22,wColors+2,1," ");
textout(handle,36,23,wColors+2,1," ");
if(choice=='1')
{
textout(handle,20,5,wColors+2,1,"伴随音乐开始一段游戏的旅程");
textout(handle,12,6,wColors+2,1," 初级 。。。。。");
textout(handle,22,8,wColors+2,1," ");
textout(handle,22,10,wColors+2,1," ");
textout(handle,22,12,wColors+2,1," ");
level=0,score=0;
PlaySound(TEXT("E:\\Microsoft Visual Studio\\MyProjects\\为我亲爱的\\moumoon - Sunshine Girl.wav"),NULL,SND_FILENAME|SND_ASYNC|SND_LOOP);
Sleep(2000);
system("CLS");
textout(handle,20,5,wColors+2,1," ");
textout(handle,22,6,wColors+2,1," ");
break;
}
else if(choice=='2')
{
textout(handle,20,5,wColors+2,1,"伴随音乐开始一段游戏的旅程");
textout(handle,22,6,wColors+2,1," 中级 。。。。。");
textout(handle,22,8,wColors+2,1," ");
textout(handle,22,10,wColors+2,1," ");
textout(handle,22,12,wColors+2,1," ");
level=2,score=20;
Sleep(2000);
system("CLS");
textout(handle,20,5,wColors+2,1," ");
textout(handle,22,6,wColors+2,1," ");
PlaySound(TEXT("E:\\Microsoft Visual Studio\\MyProjects\\为我亲爱的\\久石让 - Summer.wav"),NULL,SND_FILENAME|SND_ASYNC|SND_LOOP);
Sleep(2000);
system("CLS");
textout(handle,20,5,wColors+2,1," ");
textout(handle,22,6,wColors+2,1," ");
break;
}
else if(choice=='3')
{
textout(handle,20,5,wColors+2,1,"伴随音乐开始一段游戏的旅程");
textout(handle,12,6,wColors+2,1," 高级 。。。。。");
textout(handle,22,8,wColors+2,1," ");
textout(handle,22,10,wColors+2,1,"