问题标题: IWC 9.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 9.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);
	cout<<"↑↓←→上下左右"<<endl;
	sleep(1);
	cout<<"tfgh 上下左右添加方块"<<endl;
	sleep(1);
	cout<<"ijkl 上下左右删除方块"<<endl;
	sleep(1);
	cout<<"q 存档并退出"<<endl;
	sleep(1);
	cout<<"7秒后自动进入";
	sleep(7);
	system("cls"); 
    int x=17,y=49;
	ifstream fin;
	fin.open("cd.iwdate");
	ofstream fout;
	ofstream cfout;
	cfout.open("记录.iwiu");
	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();
        cout<<"x:"<<x<<" "<<"y:"<<y;
        char ch=getch();
        if (ch == '\xE0') {  // 特殊键前缀
	        ch = getch();
			if(ch=='P'){
	            system("cls");
	            if(a[x+1][y]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x+1][y]);
	
				
	            x+=1;
				cfout<<'↓'<<endl;
	
	        }else if(ch=='H'){
	            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;
				cfout<<'↑'<<endl;
	
	        }else if(ch=='K'){
	            system("cls");
	            if(a[x][y-1]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x][y-1]);
	            y-=1;
				cfout<<'←'<<endl;
	        }else if(ch=='M'){
	            system("cls");
	            if(a[x][y+1]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x][y+1]);
	            y+=1;
				cfout<<'→'<<endl;
	        }
	    }
        else if(ch=='i'){
            a[x-1][y]=0;

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

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

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

            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='t'){
            a[x-1][y]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='g'){
            a[x+1][y]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='f'){
            a[x][y-1]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='h'){
            a[x][y+1]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='q'){
        	system("cls");
        	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;
        }
    }
    cfout<<endl<<endl;
    cfout.close();
	fout.close();
    return 0;
}



 

宣墨一在2025-08-16 10:42:44追加了内容

有点问题

#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 9.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(2);
	cout<<"↑↓←→上下左右"<<endl;
	sleep(1);
	cout<<"tfgh 上下左右添加方块"<<endl;
	sleep(1);
	cout<<"ijkl 上下左右删除方块"<<endl;
	sleep(1);
	cout<<"q 存档并退出"<<endl;
	sleep(1);
	cout<<"7秒后自动进入";
	sleep(7);
	system("cls"); 
    int x=17,y=49;
	ifstream fin;
	fin.open("cd.iwdate");
	ofstream fout;
	ofstream cfout;
	cfout.open("记录.iwiu");
	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();
        cout<<"x:"<<x<<" "<<"y:"<<y;
        char ch=getch();
        if (ch == '\xE0') {  // 特殊键前缀
	        ch = getch();
			if(ch=='P'){
	            system("cls");
	            if(a[x+1][y]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x+1][y]);
	
				
	            x+=1;
				cfout<<"↓"<<endl;
	
	        }else if(ch=='H'){
	            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;
				cfout<<"↑"<<endl;
	
	        }else if(ch=='K'){
	            system("cls");
	            if(a[x][y-1]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x][y-1]);
	            y-=1;
				cfout<<"←"<<endl;
	        }else if(ch=='M'){
	            system("cls");
	            if(a[x][y+1]!=0){
	                system("cls");
	                continue;
	            }
	            swap(a[x][y],a[x][y+1]);
	            y+=1;
				cfout<<"→"<<endl;
	        }
	    }
        else if(ch=='i'){
            a[x-1][y]=0;

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

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

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

            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='t'){
            a[x-1][y]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='g'){
            a[x+1][y]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='f'){
            a[x][y-1]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='h'){
            a[x][y+1]=1;
            system("cls");
            cfout<<ch<<endl;
        }else if(ch=='q'){
        	system("cls");
        	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;
        }
    }
    cfout<<endl<<endl;
    cfout.close();
	fout.close();
    return 0;
}



 


0
已采纳
蒋源
蒋源
新手光能
新手光能

是加了破坏方块吗?

我有一个小建议,虽然可能有点难:

就是在脚下没有方块的时候会往下掉,现在脚下没有方块会悬空在那里,而且还可以正常左右走,不会掉下去

0
于行衍
于行衍
中级天翼
中级天翼

大牢,有实力还有新手介绍

我要回答