问题标题: IWC 7.0

1
0
已解决
宣墨一
宣墨一
初级守护
初级守护
#include<iostream>
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<unistd.h>
#include<conio.h>
#include<iomanip>
#include<fstream>
using namespace std;

int b[20][50]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
               1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
               1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
int a[20][50];
class Iwc{
    public:
        void setColor(int color) {
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
        }
        void out1(){
            for(int i=0;i<=19;i++){
                for(int j=0;j<=49;j++){
                    if(a[i][j]==1){
                        cout<<"#";
                    }else if(a[i][j]==0){
                        cout<<' ';
                    }else if(a[i][j]==2){
                        cout<<"@";
                    }
                }
                cout<<endl;
            }
        }
};


void windows(){
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO bInfo;
    GetConsoleScreenBufferInfo(hOut, &bInfo );
    SetConsoleTitle("IWC 6.0"); // 设置窗口的标题
    COORD size = {110, 30};//设置窗口大小
    SetConsoleScreenBufferSize(hOut,size);
    SMALL_RECT rc = {0,0, 110, 30};
    SetConsoleWindowInfo(hOut,true ,&rc);
}
int main(){
    windows();
    //system("color 1F");
    Iwc iwc;
    iwc.setColor(1);

    int x=17,y=49;
    ifstream fin;
    fin.open("cd.iwdate");
    ofstream fout;
    if(!fin.is_open()){
        for(int i=0;i<=19;i++){
            for(int j=0;j<=49;j++){
                a[i][j]=b[i][j];
            }
        }
    }else{
        for(int i=0;i<=19;i++){
            for(int j=0;j<=49;j++){
                int e;
                fin>>e;
                if(e==2){
                    x=i;
                    y=j;
                }
                a[i][j]=e;
            }
        }
    } 
    fin.close() ;
    while(1){
        iwc.out1();
        char ch=getch();
        if(ch=='s'){
            system("cls");
            if(a[x+1][y]!=0){
                system("cls");
                continue;
            }
            swap(a[x][y],a[x+1][y]);


            x+=1;


        }else if(ch=='w'){
            system("cls");
            if(a[x-1][y]!=0){
                system("cls");
                continue;
            }
            swap(a[x][y],a[x-1][y]);
            a[x][y]=1;
            x-=1;


        }else if(ch=='a'){
            system("cls");
            if(a[x][y-1]!=0){
                system("cls");
                continue;
            }
            swap(a[x][y],a[x][y-1]);
            y-=1;

        }else if(ch=='d'){
            system("cls");
            if(a[x][y+1]!=0){
                system("cls");
                continue;
            }
            swap(a[x][y],a[x][y+1]);
            y+=1;

        }else if(ch=='i'){
            a[x-1][y]=0;

            system("cls");
        }else if(ch=='k'){
            a[x+1][y]=0;

            system("cls");
        }else if(ch=='j'){
            a[x][y-1]=0;

            system("cls");
        }else if(ch=='l'){
            a[x][y+1]=0;

            system("cls");
        }else if(ch=='t'){
            a[x-1][y]=1;
            system("cls");
        }else if(ch=='g'){
            a[x+1][y]=1;
            system("cls");
        }else if(ch=='f'){
            a[x][y-1]=1;
            system("cls");
        }else if(ch=='h'){
            a[x][y+1]=1;
            system("cls");
        }else if(ch=='q'){
            fout.open ("cd.iwdate");
            for(int i=0;i<=19;i++){
                for(int j=0;j<=49;j++){
                    fout<<a[i][j]<<" ";

                }
                cout<<endl;
            }
            return 0;
        }else{
            system("cls");
            continue;
        }
    }
    fout.close();
    return 0;
}



按q存档

 


1
已采纳
蒋源
蒋源
资深守护
资深守护

大佬厉害

我等你加存档从1.0等到现在

我可是IWC的忠实粉丝

1
1
0
0
我要回答