我在C编程的游戏,问题是,它不带我到每个房间或给我的房间描述,也是我选择一个项目时,它不会采取项目。
我一直盯着这个代码,我的眼睛受伤。请帮助。
#include <iostream>
#include <string>
using namespace std;
int iFlag=0x00000000;
//Define Doors(nibble0)
#define DOOR_NORTH 0x00000001
#define DOOR_SOUTH 0x00000002
#define DOOR_WEST 0x00000004
#define DOOR_EAST 0x00000008
//Define Treasure Items(nibble1)
#define BOOTS 0x00000010
#define COMPASS 0x00000020
#define ACCESS_CODE 0x00000040
#define ARMY_SUIT 0x00000080
//Define harmless Creatures
#define MOUSE 0x00000100
#define BUTTERCUP 0x00000200
#define MOCKING_JAY 0x00000400
#define LADY 0x00000800
//Define dangerous creatures
#define TRACKER_JACKER 0x00001000
#define SPIDERS 0x00002000
#define GORG 0x00004000
#define MONKEY 0x00008000
//Define Dangerous
#define DEADLY 0x00010000
#define DANGEROUS 0x00020000
#define CAUTION 0x00040000
#define FRIENDLY 0x00080000
//Prototypes
void BuildRooms(unsigned int rooms[][4]);
void DescribeRoomContents(int roomDesc, int row, int col);
void DescribeRoom00_00();
void DescribeRoom00_01();
void DescribeRoom00_02();
void DescribeRoom00_03();
void DescribeRoom00_04();
void DescribeRoom01_00();
void DescribeRoom02_00();
void DescribeRoom03_00();
void DescribeRoom04_00();
void DescribeRoom01_01();
void DescribeRoom02_02();
void DescribeRoom03_03();
void DescribeRoom04_04();
void DescribeRoom01_04();
void DescribeRoom01_05();
void DescribeRoom01_06();
int TakeItem(unsigned int rooms[4][4], int row, int col, string Object);
int main()
{
string cmdVerb; // string object to hold players command verb
string cmdObj; //string object to hold players command object
int iRow;
int iCol;
int iNumRows;
int iNumCols;
int idx;
int bQuitGame;
int iPlayer=0;
int endRow=2;
int endCol=2;
//array rooms variable assignments
unsigned int panem[4][4];
//Make all array initially zero
for(int row=0; row<4;row++)
for(int col=0; col<4;col++)
panem[row][col]=0;
BuildRooms(panem);
// initialize the location variables
iRow=0;
iCol=0;
iNumRows=4;
iNumCols=4;
idx=0;
//-------------------
//end of room list
//----------------------------
//Print directions
cout<<"HOW TO PLAY"<<endl;
cout<<" "<<endl;//line of space
cout<<" "<<endl;//line of space
cout<<" "<<endl;// line of space
cout<<" It is your job to locate 4 treasure items located within the walls"<<endl;//part1
cout<<"of District 13. Navigate through all sixteen rooms by using cardinal direction."<<endl;
cout<<" "<<endl;//line of space
cout<<" Each room obtains a door, that door is found by correctly giving the cardinal"<<endl;//part2
cout<<" direction to enter that are. For example, to get into the first room you would"<<endl;
cout<<"choose North, to get into room 2 you would choose Southeast and so forth."<<endl;
cout<<" "<<endl;//line of space
cout<<" Some rooms will have creatures, some good some bad, avoid getting too close"<<endl;//part3
cout<<"to any of the genetically morphed animals, they are bad news. Some rooms will"<<endl;
cout<<"also contain useless items. You need to disregard those items and only choose"<<endl;
cout<<"the treasure items."<<endl;
cout<<" "<<endl;//line of space
cout<<" After successfully gathering all 4 items,you need"<<endl;//part4
cout<<"to find your way back to the elevator and escape District 13 before"<<endl;
cout<<"President Coin catches you. Good luck, and remember to hurry!"<<endl;
//--------------
//get all users command
//---------------------
bQuitGame=false;
while(!bQuitGame)
{
cout<<"\nWhat do you want to do?"; //Prompt User for input
cin>>cmdVerb>>cmdObj;
cout<<endl; // skip
// Converting to uppercase
idx=0;
while((unsigned)idx<cmdverb.length())>
{
cmdVerb[idx]=toupper(cmdVerb[idx]);
idx++;
}
idx=0;
while((unsigned)idx<cmdobj.length())>
{
cmdObj[idx]=toupper(cmdObj[idx]);
idx++;
}
//*****************************************
//start game loop//
//****************************************
cout<<"Command is:"<<cmdVerb<<" "<<cmdObj<<endl;
if(cmdVerb=="GO")
{
cout<<"command verb is GO"<<endl;
if(cmdObj=="NORTH")
// can we go that way
{
if(panem[iRow][iCol]&DOOR_NORTH)
{
iRow--; //Move up a row
DescribeRoomContents(panem[iRow][iCol], iRow,iCol);
}
else
cout<<"There is no door to the NORTH"<<endl;
}
else if(cmdObj=="SOUTH")
{
// can we go that way
if(panem[iRow][iCol]&DOOR_SOUTH)
{
iRow++; //Move up a row
DescribeRoomContents(panem[iRow][iCol], iRow,iCol);
}
else
cout<<"There is no door to the SOUTH"<<endl;
cout<<"Direction is South"<<endl;
}
else if(cmdObj=="WEST")
{
// can we go that way
if(panem[iRow][iCol]&DOOR_WEST)
{
iCol--; //Move up a row
DescribeRoomContents(panem[iRow][iCol], iRow,iCol);
}
else
cout<<"There is no door to the WEST"<<endl;
cout<<"Direction is West"<<endl;
}
else if (cmdObj==