我用二维数组输出的文字地图会乱,求大佬指点一下QAQ
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
#define green FOREGROUND_INTENSITY|FOREGROUND_GREEN
#define yellow FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN
#define red FOREGROUND_INTENSITY|FOREGROUND_RED
#define black FOREGROUND_INTENSITY
#define white FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN | FOREGROUND_BLUE
int zz=0,sum=0;
char dd;
int csdt[25][25]={
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,3,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,4,0,0,5,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
};
int smcs=100,flcs=3,gjcs=1;
struct st1{
int jqsm;
int jqfl;
int jqgj;
};
struct st2{
int zrsm;
int zrfl;
int zrgj;
};
struct st3{
int jssm;
int jsfl;
int jsgj;
};
struct st4{
int htsm;
int htfl;
int htgj;
};
int main(){
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
cout<<"fhhao出品,必是辣鸡";
Sleep(1000);
system("cls");
int sum=0;
while(1){
struct st1 stjq;
struct st2 stzr;
struct st3 stjs;
struct st4 stht;
stjq.jqsm=150;
stjq.jqfl=0;
stjq.jqgj=6;
stzr.zrsm=70;
stzr.zrfl=5;
stzr.zrgj=10;
stjs.jssm=90;
stjs.jsfl=2;
stjs.jsgj=1;
stht.htsm=100;
stht.htfl=0;
stht.htgj=4;
SetConsoleTextAttribute(hout, white);
cout<<"哔哔...";
Sleep(2000);
system("cls");
cout<<"一阵铃声把你从睡梦中叫醒...";
Sleep(1000);
system("cls");
cout<<"现在时间6:30";
Sleep(1000);
cout<<"你的脑里浮现了神密的杀人魔";
system("cls");
cout<<"外面下起了微微小雨";
system("cls");
cout<<"你要出去吗?Y/N";
char q;
int s;
cin>>q;
if(q=='N'){
system("cls");
cout<<"你等啊等......"<<endl;
Sleep(3000);
SetConsoleTextAttribute(hout, red);
cout<<"突然,一个人拿着斧子向你冲过来,向你乱砍"<<endl;
srand(time(NULL));
int a = rand() % 100;
if(a==5){
system("cls");
SetConsoleTextAttribute(hout, white);
cout<<"你躲开了,并跑了出去";
system("cls");
break;
}else{
cout<<"你被砍死了"<<endl;
Sleep(2000);
SetConsoleTextAttribute(hout, white);
cout<<"要继续吗 Y/N"<<endl;
cin>>q;
if(q=='Y'){
system("cls");
}
else return 0;
}
}else{
cout<<"你出去了";
system("cls");
Sleep(1000);
SetConsoleTextAttribute(hout, red);
cout<<"前面突然出现了一个牌子写着:别回头!!!";
cout<<"你要回头吗? Y/N";
cin>>q;
SetConsoleTextAttribute(hout, white);
if(q=='Y'){
system("cls");
cout<<"你回头了,发现有一个人在你房子后面,你追上了他"<<endl;
cout<<"你掉进了一个洞穴"<<endl;
Sleep(1000);
cout<<"有两条道路,你要走哪条? 1/2"<<endl;
cin>>s;
if(s==1){
SetConsoleTextAttribute(hout, red);
cout<<"一个毒蜘蛛从墙壁上跳了下来,并咬了你一口";
srand(time(NULL));
int a = rand() % 100;
if(a==9){
SetConsoleTextAttribute(hout, yellow);
cout<<"恭喜你,解锁了隐藏病毒!";
zz=1;
cout<<"要继续吗 Y/N";
cin>>q;
if(q=='Y')
system("cls");
else return 0;
}else{
system("cls");
SetConsoleTextAttribute(hout, white);
cout<<"你被毒死了";
cout<<"要继续吗 Y/N";
cin>>q;
if(q=='Y')
system("cls");
else return 0;
}
}else{
system("cls");
cout<<"你发现了一个实验室,门牌上用一种红色液体写着:"<<endl;
SetConsoleTextAttribute(hout, red);
cout<<" 人体研究室"<<endl;
cout<<" 研究生化武器"<<endl;
cout<<" 闲人勿进"<<endl;
SetConsoleTextAttribute(hout, white);
cout<<"你发现门没锁,好像刚刚被人开过"<<endl;
cout<<"你要进入吗?"<<endl<<"Y/N"<<endl;
cin>>q;
system("cls");
if(q=='Y'){
while(1){
cout<<"你进入了实验室"<<endl;
cout<<"你看见里面有四个瓶子"<<endl;
cout<<"请选择查看 1~4"<<endl;
cout<<"前往下一个区域按9"<<endl;
cin>>s;
if(s==9)break;
if(s==1){
system("cls");
cout<<" 机械病毒"<<endl;
cout<<"感染后,身体会一点点变成机器"<<endl;
cout<<"1,退出"<<endl;
cin>>s;
}else if(s==2){
system("cls");
cout<<" 人体自燃病毒"<<endl;
cout<<"感染后,人会燃烧"<<endl;
cout<<"1,退出"<<endl;
cin>>s;
}else if(s==3){
system("cls");
cout<<" 僵尸病毒"<<endl;
cout<<"感染后,人会变成僵尸"<<endl;
cout<<"1,退出"<<endl;
cin>>s;
}else if(s==4){
system("cls");
cout<<" 合体病毒"<<endl;
cout<<"感染后,人可以跟其他生物合体"<<endl;
cout<<"1,退出"<<endl;
cin>>s;
}
system("cls");
}
cout<<"你要选择哪个病毒来感染1~4 按0不感染"<<endl;
cin>>s;
if(s==1){
smcs=stjq.jqsm;
flcs=stjq.jqfl;
gjcs=stjq.jqgj;
}else if(s==2){
smcs=stzr.zrsm;
flcs=stzr.zrfl;
gjcs=stzr.zrgj;
}else if(s==3){
smcs=stjs.jssm;
flcs=stjs.jsfl;
gjcs=stjs.jsgj;
}else if(s==4){
smcs=stht.htsm;
flcs=stht.htfl;
gjcs=stht.htgj;
}
system("cls");
cout<<"突然,一阵狂风把你卷走";
Sleep(2000);
system("cls");
while(1){
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(sum==16){
cout<<endl;
sum=0;
}
if(csdt[i][j]==1)SetConsoleTextAttribute(hout, white),cout<<"墙"<<" ",sum++;
if(csdt[i][j]==0||csdt[i][j]==3)SetConsoleTextAttribute(hout, green),cout<<"草"<<" ",sum++;
if(csdt[i][j]==5)SetConsoleTextAttribute(hout, red),cout<<"告"<<" ",sum++;
if(csdt[i][j]==4)SetConsoleTextAttribute(hout, yellow),cout<<"你"<<" ",sum++;
}
}
SetConsoleTextAttribute(hout, white);
cout<<endl<<"你环顾四周,发现了一个告示牌";
dd=getch();
if(dd='a'){
}
}
}else{
SetConsoleTextAttribute(hout, red);
cout<<"突然,你感觉背后凉风阵阵"<<endl;
cout<<"你回过头,发现了斧头杀人魔"<<endl;
cout<<"你被砍死了";
cout<<"要继续吗 Y/N";
cin>>q;
if(q=='Y')
system("cls");
else return 0;
}
}
}else{
cout<<"FUCK YOU!!!"<<endl;
cout<<"你被震死了";
cout<<"要继续吗 Y/N";
cin>>q;
if(q=='Y')
system("cls");
else return 0;
}
}
}
}