#include<iostream>
#include<conio.h>
#include<windows.h>
#include<ctime>
#ifndef FONTCOLOR_H_
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
#endif
using namespace std;typedef unsigned long long ull;
void red_print(std::string out); void green_print(std::string out);
void black_print(std::string out);void yellow_print(std::string out);
void blue_print(std::string out);void purple_print(std::string out);
void cyan_print(std::string out);void dark_blue_print(std::string out);
void white_print(std::string out);
int randNext(int left, int right){
static unsigned int seed = 0;seed++;
srand((unsigned) time(NULL) + seed * seed);
return rand() % (right - left + 1) + left;}
void COLOR_PRINT(int color){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);cout<<" ";
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);}
void SB(int color){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);cout<<"SB";
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);}
short map[32][32];unsigned short x=1,y=1;char moves;int color=1;
void does(){for(int i = 1;i<31;i++)for(int j = 1;j<31;j++)map[i][j]=666;
while(moves=getch()){system("cls");
if(moves=='w'&&(x-1)!=0&&map[x-1][y]==666)x--;
if(moves=='s'&&(x+1)!=31&&map[x+1][y]==666)x++;
if(moves=='a'&&(y-1)!=0&&map[x][y-1]==666)y--;
if(moves=='d'&&(y+1)!=31&&map[x][y+1]==666)y++;
if(moves=='i')if(map[x-1][y]!=0) map[x-1][y]=666;
if(moves=='k')if(map[x+1][y]!=0) map[x+1][y]=666;
if(moves=='j')if(map[x][y-1]!=0) map[x][y-1]=666;
if(moves=='l')if(map[x][y+1]!=0) map[x][y+1]=666;
if(moves=='t')if(map[x-1][y]!=0) map[x-1][y]=color;
if(moves=='g')if(map[x+1][y]!=0) map[x+1][y]=color;
if(moves=='f')if(map[x][y-1]!=0) map[x][y-1]=color;
if(moves=='h')if(map[x][y+1]!=0) map[x][y+1]=color;
if(moves=='c') cin>>color;
for(int i = 0;i<32;i++){for(int j = 0;j<32;j++){
if(x==i&&y==j){SB(240);continue;}if(map[i][j]==666)COLOR_PRINT(127);
if(map[i][j]==0) COLOR_PRINT(111);if(map[i][j]==1) COLOR_PRINT(320);
if(map[i][j]==2) COLOR_PRINT(480);if(map[i][j]==3) COLOR_PRINT(943);
if(map[i][j]==4) COLOR_PRINT(944);if(map[i][j]==5) COLOR_PRINT(927);
if(map[i][j]==6) COLOR_PRINT(879);if(map[i][j]==7) COLOR_PRINT(848);
if(map[i][j]==8) COLOR_PRINT(384);if(map[i][j]==9) COLOR_PRINT(512);
}cout<<endl;}cout<<"x:"<<x<<" "<<"y:"<<y<<endl;
COLOR_PRINT(320);cout<<"1 ";COLOR_PRINT(480);cout<<"2 ";COLOR_PRINT(943);cout<<"3 ";
COLOR_PRINT(944);cout<<"4 ";COLOR_PRINT(927);cout<<"5 ";COLOR_PRINT(879);cout<<"6 ";
COLOR_PRINT(848);cout<<"7 ";COLOR_PRINT(384);cout<<"8 ";COLOR_PRINT(512);cout<<"9 ";
cout<<endl<<color; }}int main(){does();}
WASD:控制上下移动
TFGH:放置方块
IJKL:消除方块
C:输入颜色,列表在下方
原创!!!