问题标题: 酷町堂:游戏小更新 行走 2.1.4 为c++奋斗!!!

1
0
已解决
王子逸
王子逸
新手天翼
新手天翼
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<conio.h>
#include<Windows.h>
#include<string>
using namespace std;
void suo()
{
	string ya="a键向左移动,b键向右移动,w爬墙,s下墙,z键在脚下放方块";
	cout<<"\n\n\n\n\n\n\n\n\t\t\t";
	for(int i=0;i<ya.size();i++)
	{
		cout<<ya[i];
		Sleep(130);
	 } 
	 Sleep(3000);
	 system("cls");
}
int main()
{
HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE);
    						HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
	system("color 04");
	int x=8,y=31;
	char ch;
	int a[11][36]={{1,1,1,1,1,1,1,1,1,1,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
				  {0,0,0,0,0,0,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,0,0,0,0,0},
				  {0,0,0,0,0,0,0,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,0,0,0,0},
				  {0,0,0,0,0,0,0,0,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,0,0,0},
				  {0,0,0,0,0,0,0,0,0,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,0,0},
				  {0,0,0,0,0,0,0,0,0,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},
				  {1,1,0,0,0,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,9,0,0,0,0},
				  {1,1,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1},
				  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

suo(); 
				  while(1)
				  {
				for(int i=0;i<=10;i++)
				{
				  	for(int j=0;j<=35;j++)
				  	{
				  		if(a[i][j]==1)
				  		{
						  SetConsoleTextAttribute(hstdout, 0x0C);
				  			cout<<"OT";
						  } 
						  
						  else if(a[i][j]==0)
						  {
						  	cout<<"  ";
						  }
						  else if(a[i][j]==9)
						  {
    						SetConsoleTextAttribute(hstdout, 0x0E);
					   	  	cout<<"GD";
						  }
						  else if(a[i][j]==8)
						  { 
						  SetConsoleTextAttribute(hstdout, 0x0F);
						  	cout<<"MM"; 
						  }
					  }
					  cout<<endl; 
				}
				ch=getch();
				if(ch=='a')
				{
					if(a[x+1][y-1]==8)
					{
						system("cls");
						system("color 0F");
						cout<<"\n\n\n\n\t\t\t\t\tGame Over!\n\n\n\n\n\n\n";
						Sleep(5000);
						return 0;
					}
					else if(a[x+1][y-1]==0&&a[x+1][y]!=1)
					{
						a[x+1][y-1]=9;
						a[x][y]=0;
						x++;
						y--;
						system("cls");
					}
					else if(a[x][y-1]==1&&a[x-1][y-1]!=1)
					{
						a[x-1][y-1]=9;
						a[x][y]=0;
						x--;
						y--;
						system("cls");
					}
					else
					{
					a[x][y-1]=9;
					a[x][y]=0;
					y--;
					system("cls");
					}
				}
				else if(ch=='z'&&a[x-1][y]!=1)
				{
					a[x][y]=1;
					a[x-1][y]=9;
					x-=1;
					system("cls"); 
				 } 
				else if(ch=='d')
				{
					if(a[x+1][y+1]==8)
					{
						system("cls");
						system("color 0F") ;
						cout<<"\n\n\n\n\t\t\t\t\tGame Over!\n\n\n\n\n\n\n";
						Sleep(5000);
						return 0;
					}
					else if(a[x+1][y+1]==0&&a[x-1][y+1]!=1)
					{
						a[x+1][y+1]=9;
						a[x][y]=0;
						x++;
						y++;
						system("cls");
					 } 
					 else if(a[x][y+1]==1)
					 {
					 	a[x-1][y+1]=9;
					 	a[x][y]=0;
					 	x--;
					 	y++;
					 	system("cls");
					 }
					 
					 else
					 {
					 	a[x][y+1]=9;
					a[x][y]=0;
					y++;
					system("cls");
					 }
					
				}
				else if(ch=='w'&&a[x-1][y]!=1&&(a[x][y+1]||a[x][y-1]==1)) 
				{
					a[x-1][y]=9;
					a[x][y]=0;
					x--;
					system("cls");
				}
				else if(ch=='s'&&a[x+1][y]!=1&&(a[x][y+1]||a[x][y-1]==1))
				{
					a[x+1][y]=9;
					a[x][y]=0;
					x++;
					system("cls");
				} 
				else
				{
					system("cls");
				}
				}
				return 0;
}

 

王子逸在2020-05-23 17:59:58追加了内容

收集更新意见

 

 

 

 

 

 

王子逸在2020-05-23 18:35:58追加了内容
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<conio.h>
#include<Windows.h>
#include<string>
using namespace std;
void suo()
{
	string ya="a键向左移动,d键向右移动,w爬墙,s下墙,z键在脚下放方块";
	cout<<"\n\n\n\n\n\n\n\n\t\t\t";
	for(int i=0;i<ya.size();i++)
	{
		cout<<ya[i];
		Sleep(130);
	 } 
	 Sleep(3000);
	 system("cls");
}
int main()
{
HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE);
    						HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
	system("color 04");
	int x=8,y=31;
	char ch;
	int a[11][36]={{1,1,1,1,1,1,1,1,1,1,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
				  {0,0,0,0,0,0,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,0,0,0,0,0},
				  {0,0,0,0,0,0,0,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,0,0,0,0},
				  {0,0,0,0,0,0,0,0,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,0,0,0},
				  {0,0,0,0,0,0,0,0,0,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,0,0},
				  {0,0,0,0,0,0,0,0,0,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},
				  {1,1,0,0,0,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,9,0,0,0,0},
				  {1,1,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1},
				  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

suo(); 
				  while(1)
				  {
				for(int i=0;i<=10;i++)
				{
				  	for(int j=0;j<=35;j++)
				  	{
				  		if(a[i][j]==1)
				  		{
						  SetConsoleTextAttribute(hstdout, 0x0C);
				  			cout<<"OT";
						  } 
						  
						  else if(a[i][j]==0)
						  {
						  	cout<<"  ";
						  }
						  else if(a[i][j]==9)
						  {
    						SetConsoleTextAttribute(hstdout, 0x0E);
					   	  	cout<<"GD";
						  }
						  else if(a[i][j]==8)
						  { 
						  SetConsoleTextAttribute(hstdout, 0x0F);
						  	cout<<"MM"; 
						  }
					  }
					  cout<<endl; 
				}
				ch=getch();
				if(ch=='a')
				{
					if(a[x+1][y-1]==8)
					{
						system("cls");
						system("color 0F");
						cout<<"\n\n\n\n\t\t\t\t\tGame Over!\n\n\n\n\n\n\n";
						Sleep(5000);
						return 0;
					}
					else if(a[x+1][y-1]==0&&a[x+1][y]!=1)
					{
						a[x+1][y-1]=9;
						a[x][y]=0;
						x++;
						y--;
						system("cls");
					}
					else if(a[x][y-1]==1&&a[x-1][y-1]!=1)
					{
						a[x-1][y-1]=9;
						a[x][y]=0;
						x--;
						y--;
						system("cls");
					}
					else
					{
					a[x][y-1]=9;
					a[x][y]=0;
					y--;
					system("cls");
					}
				}
				else if(ch=='z'&&a[x-1][y]!=1)
				{
					a[x][y]=1;
					a[x-1][y]=9;
					x-=1;
					system("cls"); 
				 } 
				else if(ch=='d')
				{
					if(a[x+1][y+1]==8)
					{
						system("cls");
						system("color 0F") ;
						cout<<"\n\n\n\n\t\t\t\t\tGame Over!\n\n\n\n\n\n\n";
						Sleep(5000);
						return 0;
					}
					else if(a[x+1][y+1]==0&&a[x-1][y+1]!=1)
					{
						a[x+1][y+1]=9;
						a[x][y]=0;
						x++;
						y++;
						system("cls");
					 } 
					 else if(a[x][y+1]==1)
					 {
					 	a[x-1][y+1]=9;
					 	a[x][y]=0;
					 	x--;
					 	y++;
					 	system("cls");
					 }
					 
					 else
					 {
					 	a[x][y+1]=9;
					a[x][y]=0;
					y++;
					system("cls");
					 }
					
				}
				else if(ch=='w'&&a[x-1][y]!=1&&(a[x][y+1]||a[x][y-1]==1)) 
				{
					a[x-1][y]=9;
					a[x][y]=0;
					x--;
					system("cls");
				}
				else if(ch=='s'&&a[x+1][y]!=1&&(a[x][y+1]||a[x][y-1]==1))
				{
					a[x+1][y]=9;
					a[x][y]=0;
					x++;
					system("cls");
				} 
				else
				{
					system("cls");
				}
				}
				return 0;
}

改一下哈


0
已采纳
沈峻宇
沈峻宇
资深天翼
资深天翼

有点问题!建议将MM(尖刺)改成英文shift+6(就是^)会更好

而且可以把墙打穿!

下降过程中接触方块是按s,打穿墙壁!

望修改

沈峻宇在2020-05-24 14:06:32追加了内容

这个贴的第二版有点问题,会有输入白点乱闪,建议出版这个帖的第一版

沈峻宇在2020-05-24 14:06:51追加了内容

还是点个赞!

0
0
0
张弘毅
张弘毅
高级守护
高级守护

我想问一下,这啥怎么回事?玩着玩着怎么就 Game Over了?

 

张弘毅在2020-05-24 14:08:48追加了内容

我竟然没死!!!

0
张弘毅
张弘毅
高级守护
高级守护

要是能有个终点,走过终点还会有别的关卡,那就更好了

0
0
徐子宸
徐子宸
中级天翼
中级天翼

吐槽:是d向右移动!!!

建议:在某个地方插个小红旗,取到了就通关,然后打印第二关,进入第二关(估计你不会)

评价:还是不错的!(难度还是有滴)

请求:望采纳!

 

0
徐子宸
徐子宸
中级天翼
中级天翼

吐槽:是d向右移动!!!

建议:在某个地方插个小红旗,取到了就通关,然后打印第二关,进入第二关(估计你不会)

评价:还是不错的!(难度还是有滴)

请求:望采纳!

 

我要回答