if(rotate_tank==3)
{
drawTank_one = false;
Xloc++;
HexType = HexGrid[Yloc][Xloc];
if (HexType == 1)
{
move_x += 15.0f;
}
cout << Yloc << " " << Xloc << " " << HexType << endl;
}
One problem with the above code is that you increment the Xloc whether the new location is acceptable or not. You do not want to increment Xloc unless you actually want to move the tank. But to find out if you want to move the tank you have to test the new grid location first. . .
So, I would think you'd want something more like this instead :
if(rotate_tank==3)
{
drawTank_one = false;
// we want to test a new location to see if it is good for a move.
// get the x value for the proposed new location
int TestXLoc = Xloc + 1;
// find out what HexType is at that new location.
HexType = HexGrid[Yloc][TestXLoc];
// we can output what we've got that the new location
cout << Yloc << " " << TestXLoc << " " << HexType << endl;
if (HexType == 1) // this means the new location is good to move to
{
// now we can actually update the tank position
Xloc = TestXLoc;
move_x += 15.0f; // what is move_x doing?
}
}