⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.cpp

📁 巫魔世界是一个被墙所环绕的二维格子世界
💻 CPP
字号:
#include"wupus.h"

void Wupus_World::show(bool wait)
{   
	_sleep(480);
	system("cls");
   int x; 
   int y;
  cout << endl;
  for(y=MAX_Y; y >0; y--)
  {
    for(x=1; x <=MAX_X; x++)
    {
      if((x==hunter.pos->x) && (y==hunter.pos->y) && (world[x][y]==Empty))
		{
		  char h;//英雄的转向标志
	      if		(hunter.direction==N)	h='^';
		  else if	(hunter.direction==S)	h='v';
		  else if	(hunter.direction==W)	h='<';
		  else if	(hunter.direction==E)	h='>';
		  cout<<h<<' '<<' '<<' ';
		  cout.flush();
		  if(wait==true)
		  _sleep(100);
		}	

		 else if(world[x][y]==Living_Wupus)
		 {  
			 cout<< "W   ";
			 cout.flush();
		    if(wait==true)
		 	_sleep(100);
		 }
		 else if(world[x][y]==Dead_Wupus)
		 {
			 cout<< "D   ";
			 cout.flush();
			 if(wait==true)
			  _sleep(100);
		 }
		 else if(world[x][y]==Pit)
		 {
			 cout<< "P   ";
			 cout.flush();
			 if(wait==true)
			  _sleep(100);
		 }
		 else if(world[x][y]==Gold)
		 {
			 cout<< "G   ";
			 cout.flush();
			 if(wait==true)
			  _sleep(100);
		 }
		 else if(hunter.image[x][y]==SAFE)
		 {
			 cout<< "_   ";
			 cout.flush();
			 if(wait==true)
			  _sleep(100);
		 }

		 else if(hunter.image[x][y]==WUPUS_DANGER_POS)
		 {
			 cout<< "*   ";
			 cout.flush();
			 if(wait==true)
			  _sleep(100);
		 }
		 else     
		 {	  cout<< "?   ";//未访问
		      cout.flush();
		     if(wait==true)
			  _sleep(100);
		 }
	}
    cout<<endl<<endl;
  }
  cout << "HunterIs Now at  ("<<hunter.pos->x<<","<<hunter.pos->y<<")"<<endl<<endl;
  cout << "Direction of hunter is ";
  switch(hunter.direction)
  {
    case N: cout << "North" << endl; break;
    case E: cout << "East" << endl; break;
    case S: cout << "South" << endl; break;
    case W: cout << "West" << endl; break;
  };
  cout<<endl;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -