问题标题: IWC 2.0

3
0
已解决
宣墨一
宣墨一
新手守护
新手守护
#include<iostream>
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<unistd.h>
#include<conio.h>
#include<iomanip>
using namespace std;
int b[20][30]={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,
               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,
               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,
               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,
               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,
               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,
               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,
               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,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};
void out1(){
    for(int i=0;i<=29;i++){
        for(int j=0;j<=29;j++){
            if(b[i][j]==1){
                cout<<'#';
            }else if(b[i][j]==0){
                cout<<' ';
            }else if(b[i][j]==2){
                cout<<'@';
            }
        }
        cout<<endl;
    }
}
void windows(){
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO bInfo;
    GetConsoleScreenBufferInfo(hOut, &bInfo );
    SetConsoleTitle("IWC 2.0"); // 设置窗口的标题
    COORD size = {110, 30};//设置窗口大小
    SetConsoleScreenBufferSize(hOut,size);
    SMALL_RECT rc = {0,0, 110, 30};
    SetConsoleWindowInfo(hOut,true ,&rc);
}
int main(){
    windows();
    int x=17,y=29;
    while(1){
        out1();
        char ch=getch();
        if(ch=='s'){
            system("cls");
            if(b[x+1][y]!=0){
                system("cls");
                continue;
            }
            swap(b[x][y],b[x+1][y]);


            x+=1;


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


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

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

        }
    }
    return 0;
}

w 脚下垫方块

s 下

a 左

d 右


0
0
0
0
郑皓予
郑皓予
新手光能
新手光能

又更新了!!问一下怎么让输入按一下就行,不用enter键能直接输入

我要回答