我的世界创造1.1.50

大家好,我是LCR
如果喜欢这篇文章的话,那就动动小手点个赞吧

更新内容

  1. 修复退格键(Backspace)退至运行界面边缘就会终止程序的情况
  2. 新增图标"┼",使程序更具可玩性
  3. 修复部分显示问题,游玩体验更流畅

更新代码

首先是Backspace的修改:

if((int)a==8){
	gotoxy(x,y);
	cout<<"  ";
	f[x][y]=0;
	x-=2;
	gotoxy(x,y);  //代码整体顺序更换
	if(x<2) x=99; //此处修改
}

其次是新增图标与显示问题:

if(a=='e'){
	bj++;
	const int mun=8;
	if(bj%mun==1)
		yangshi="█ ";
	if(bj%mun==2)
		yangshi="●";
	if(bj%mun==3)
		yangshi="◎";
	if(bj%mun==4)
		yangshi="╳ ";//这里加了个空格
	if(bj%mun==5)
		yangshi="○";
	if(bj%mun==6)
		yangshi="┼ ";//新增,并且加了个空格
	if(bj%mun==7)
		yangshi="★ ";
	if(bj%mun==0)
		yangshi="";
}

总代码

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
using namespace std;
	int f[1005][1005];
	
	void color(int a);
	void gotoxy(int x,int y);
	
	void color (int a) {
	    if (a == 0 || a == 14 || a == 20) {
	    	SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
		} else if (a == 1 || a == 12) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
		} else if (a == 2) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_GREEN);
		} else if (a == 3) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
		} else if (a == 4 || a == 11) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_RED);
		} else if (a == 5 || a == 13) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
		} else if (a == 7) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_GREEN|FOREGROUND_BLUE);
		} else if (a == 15) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
		} else if (a == 16) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
		} else if (a == 17) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);
		} else if (a == 8) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
		} else if (a == 6) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_BLUE);
		} else if (a == 9) {
			SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_RED|BACKGROUND_GREEN);
		}
	}
	
	void gotoxy(int x,int y){
		COORD p;
		HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
		p.X=x;
		p.Y=y;
		SetConsoleCursorPosition(handle,p);
	}
	//◎●★█┪┓╮╯╳↖  ↗↙  ↘←┼ →↑↓〔●〕﹝○﹞
	int main(){
		int bj=0,lor=0;
		char a;
		string yangshi;
		int x=0,y=2;
		cout<<"请自己创建世界(全屏效果最好)...\n";
		cout<<"w/s/a/d移动并创建  Esc退出游戏  e更换创造样式  Backspace撤销... c切换颜色\n";
		getche();
		system("cls");
		gotoxy(x,y);
		color(lor);
		yangshi="◎";
		while(1){
			gotoxy(0,0);
			cout<<"w/s/a/d移动并创建  Esc退出游戏  e更换创造样式  Backspace撤销  c切换颜色\n"; 
			color(0);
			gotoxy(80,20);
			if(yangshi!="")cout<<"当前创造样式:";
			color(lor);
			cout<<yangshi; 
			if(yangshi=="")cout<<"当前创造样式:无";
			gotoxy(x,y);
			a=getch();
			if((a=='w'&&f[x][y-1]==0)){
				if(yangshi!="")f[x][y]=1;
				y--;
				gotoxy(x,y);
				color(lor);
				cout<<yangshi;
			}
			if((a=='s'&&f[x][y+1]==0)){
				if(yangshi!="")f[x][y]=1;
				y++;
				gotoxy(x,y);
				color(lor);
				cout<<yangshi;
			}
			if((a=='a'&&f[x-2][y]==0)){ 
				if(yangshi!="")f[x][y]=1;
				x-=2;
				gotoxy(x,y);
				color(lor);
				cout<<yangshi;
			}
			if((a=='d'&&f[x+2][y]==0)){
				if(yangshi!="")f[x][y]=1;
				x+=2;
				gotoxy(x,y);
				color(lor);
				cout<<yangshi;
			}
			if(a=='k'){
				break;
			}
			if(a=='e'){
				bj++;
				const int mun=8;
				if(bj%mun==1)
					yangshi="█ ";
				if(bj%mun==2)
					yangshi="●";
				if(bj%mun==3)
					yangshi="◎";
				if(bj%mun==4)
					yangshi="╳ ";
				if(bj%mun==5)
					yangshi="○";
				if(bj%mun==6)
					yangshi="┼ ";
				if(bj%mun==7)
					yangshi="★ ";
				if(bj%mun==0)
					yangshi="";
			}
			if((int)a==27){
				gotoxy(0,30);
				exit(0);
			}
			if((int)a==8){
				gotoxy(x,y);
				cout<<"  ";
				f[x][y]=0;
				x-=2;
				gotoxy(x,y);
				if(x<2) x=99; 
			}
			if(a=='c'){
				lor++;
				if(lor>15) lor=0;
			}
		}
		color(0);
		return 0;
	}

谢谢大家,喜欢的话请点个赞吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值