/*
实现思路:
表格:
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|
----------------------------------------------------------
##表示格子中有方块
..表示格子中没有方块
其余与俄罗斯方块一样
*/
#include"cinrc++.h"
#define cls system("cls")
#define f(sth) printf("%c",sth)
#define red FOREGROUND_RED
#define blue FOREGROUND_BLUE
#define green FOREGROUND_GREEN
#define grey FOREGROUND_INTENSITY
#define gray FOREGROUND_INTENSITY
#define sleep Sleep
/*一些基本操作*/
void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput, scrn);
}
void color(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
void color_none(){
color(15,0);
}
#define black 0
void slow(const char ch[]){
for(int i=0;ch[i];i+=2){
if(ch[i]==' '){f(ch[i--]);continue;}
if((int)ch[i]<=0){
f(ch[i]);
f(ch[i+1]);
}else{
f(ch[i]);
i--;
}
sleep(200);
}
f('\n');
sleep(500);
}
void setsize(int col, int row){
char cmd[64];
sprintf(cmd, "mode con cols=%d lines=%d", col, row);
system(cmd);
}
void startup();
void course();
void game();
void drawmap();
//struct diamond{
// int height;
// int width;
// vector<pair<int,int>>dmd;
// string str[10];
// void operator=(string s){
// int idx=-1;
// for(int i=0,j=0;i<s.size();i++,j++){
// if(s[i]=='\n'){
// ++idx;
// j=-1;
// continue;
// }
// if(!(i&1))if(s[i]=='#')dmd.push_back({idx,j>>1});
// str[idx]+=s[i];
// height=i+1;
// width=str[i].size();
// }
// }
// void operator=(char*ch){
// operator=((string)ch);
// }
// void operator=(diamond d){
// height=d.height;
// width=d.width;
// dmd.clear();
// for(auto i:d.dmd){
// dmd.push_back(i);
// }
// for(int i=0;i<10;i++){
// str[i]=d.str[i];
// }
// }
//};
//void operator<<(ofstream ofs,diamond dmd){
// for(int i=0;dmd.str[i].size();i++){
// ofs<<dmd.str[i]<<"\n";
// }
//}
//struct revolve_diamond{
// diamond d[4];
// diamond revolve(diamond dmd){
// diamond ans;
// ans.height=dmd.width;
// ans.width=dmd.height;
// for(int i=0;i<dmd.height;i++){
// for(int j=0;j<dmd.width;j++){
// dmd
// }
// }
// }
// void operator=(string s){
// d[0]=s;
// }
// void operator=(char*ch){
// operator=((string)ch);
// }
//};
//const revolve_diamond d[8]={
//R"(
//##
//##
//##
//)",
//R"(
//####
//..##
//..##
//)",
//R"(
//####
//##..
//##..
//)",
//R"(
//##..
//####
//..##
//)",
//R"(
//..##
//####
//##..
//)",
//R"(
//######
//....##
//....##
//)",
//R"(
//######
//##....
//##....
//)",
//R"(
//######
//..##..
//..##..
//)"
//};
int main(){
HideCursor();
start:
startup();
goto start;
return 0;
}
void startup(){
start:
setsize(22,5);
cls;
printf(" ");
color(red|grey,red|green|blue|grey);
slow("欢迎来到俄罗斯方块");
color(red,black);
slow(" 0.退出");
color(green,black);
slow(" 1.开始游戏");
color(blue,black);
slow("2.新手教程(新人必看)");
kb:
fflush(stdin);
while(!kbhit());
char t=getch();
fflush(stdin);
switch(t){
case '0':
cls;
color(red|grey,green|grey);
slow("感谢游玩!");
color(0,0);
exit(0);
break;
case '1':
cls;
game();
break;
case '2':
cls;
course();
break;
case '\n':
goto kb;
break;
case '\r':
goto kb;
break;
case ' ':
goto kb;
break;
default:
cls;
color(red|grey,green|grey);
slow("输入错误!");
sleep(3000);
color_none();
goto start;
}
color_none();
}
void game(){
drawmap();
while(1){
}
}
void course(){
}
void drawmap(){
color(15,green|grey);
setsize(58,39);
for(int i=1;i<=19;i++){
for(int j=1;j<=58;j++)putchar('-');
putchar('\n');
for(int j=1;j<=38;j++){
if(j&1)putchar('|');
putchar('.');
}
putchar('|');
putchar('\n');
}
for(int j=1;j<=58;j++)putchar('-');
}