随便做了个东西,谁帮我改进一下

如下

#include<iostream>
#include<conio.h>
#include<stdio.h>
const char* map[40][40];
int main()
{
	int x=5,y=5,a,b;
	bool gamestart = 1,up,down,left,right;
	for(a=0;a<40;a++)
	    for(b=0;b<40;b++) 
	    	map[a][b]="x";
	for(a=1;a<39;a++)
	    for(b=1;b<39;b++) 
	    	map[a][b]=" "; 
	map[3][31]="x"; 
	map[1][31]="x"; 
	map[2][31]="x"; 
	for(a=31;a<=38;a++)
	{
		map[3][a]="x";
	}
	map[3][34]=" ";
	map[3][35]=" ";
    map[y][x]="o";            //sidio出品 
	while(gamestart)
	{
		for(a=0;a<40;a++){for(b=0;b<40;b++){std::cout<<map[a][b];} std::cout<<std::endl;}
		std::cout<<y<<" "<<x; 
		char ch = _getch();
		up=1,down=1,left=1,right=1;
		if(ch=='w')
		{
			if(map[y-1][x]!=" "){up=0;}
			if(up!=0)
			{
				map[y-1][x]="o";
				map[y][x]=" ";
				y-=1;
			}
		}
		if(ch=='s')
		{
			if(map[y+1][x]!=" "){down=0;}
			if(down!=0)
			{
				map[y+1][x]="o";
				map[y][x]=" ";
				y+=1;
			}
		}
		if(ch=='a')
		{
			if(map[y][x-1]!=" "){left=0;}
			if(left!=0)
			{
				map[y][x-1]="o";
				map[y][x]=" ";
				x-=1;
			}
		}
	    if(ch=='d')
		{
			if(map[y][x+1]!=" "){right=0;}
			if(right!=0)
			{
				map[y][x+1]="o";
				map[y][x]=" ";
				x+=1;
			}
		}
		system("cls");
	}
    return 0;
}

这玩意我写了2天呢,看在这么努力的份上,点个赞呗(doge)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值