i am trying to use my program to move north, east, south, west using the first letter of the full word. though, whenever i run my code and get to this point my coordinates do not update and i remain stuck at 4,6(or 5,6). can anyone help me with this please.
(i will change my goto command after this, it is not efficient coding.)
int counter = Character(9); //later on for events
int F_LocationX = 4, F_LocationY = 5, C_LocationX = 4, C_LocationY = 5; //locations
string Direction = "i"; //to define a direction later
cout<<""<<endl
<<"you are in the center of the map"<<endl
<<"what direction would you like to take?"<<endl;
cin>>Direction[1];
while((Direction[1] != 'L')||(Direction[1] != 'l')) //exploration loop
{
if((Direction[1] == 'n')||(Direction[1] == 'N'))
{
C_LocationY = C_LocationY + 1;
}
if((Direction[1] == 's')||(Direction[1] == 'S'))
{
C_LocationY = C_LocationY - 1;
}
if((Direction[1] == 'e')||(Direction[1] == 'E'))
{
C_LocationX = C_LocationX + 1;
}
if((Direction[1] == 'w')||(Direction[1] == 'W'))
{
C_LocationX = C_LocationX - 1;
}
else if((Direction[1] == 'L')||(Direction[1] == 'l'))
{
break;
}
F_LocationX = C_LocationX;
F_LocationY = C_LocationY;
cout<<C_LocationX<<","<<C_LocationY<<endl; //coordinates
//very likely the problem is above this point
int Encounter = (rand() % 4) +1; //battle
if(Encounter == 1)
{
cout<<"you have entered into battle"<<endl;
Character(11);
}
F_LocationY = F_LocationY + 1; //location west
if(F_LocationX == 1)
{
cout<<"you cannot go west"<<endl;
}
F_LocationY = F_LocationY - 1; //location east
if(F_LocationX == 10)
{
cout<<"you cannot go east"<<endl;
}
F_LocationX = F_LocationX + 1; //location north
if(F_LocationY == 10)
{
cout<<"you cannot go north"<<endl;
}
F_LocationX = F_LocationX - 1; //location south
if(F_LocationY == 1)
{
cout<<"you cannot go south"<<endl;
}
Decider:
int No;
No = 0;
cout<<"what direction do you wish to go?"<<endl;
cin>>Direction;
if(C_LocationX == 0)
{
cout<<"you cannot go west"<<endl;
C_LocationX = C_LocationX +1;
No = 1;
}
if(C_LocationX == 11)
{
cout<<"you cannot go east"<<endl;
C_LocationX = C_LocationX - 1;
No = 1;
}
if(C_LocationY == 11)
{
cout<<"you cannot go north"<<endl;
C_LocationY = C_LocationY - 1;
No = 1;
}
if(C_LocationY == 0)
{
cout<<"you cannot go south"<<endl;
C_LocationY = C_LocationY + 1;
No = 1;
}
if(No == 1)
{
cout<<"you cannot go there"<<endl;
goto Decider;
}
}//end of while
return 0;