I have some code to draw a grid with simple characters like | | | for verticals and ----------------- for the horizontal line.
But as you play the game for some reason one of the rows gets shifted to the right. I have no clue why this happens. Even initially the zeroth row gets shifted
int blankflag = 0;
cout << "\n ------------------------------------------------- ";
for (int i = 4; i >= 0; i--)
{
cout << "\n";
cout << i;
for (int j = 0; j <= 4; j++)
{
if (blankflag)
{
cout << " |";
blankflag = 0;
}
else
{
cout << " |";
}
for (int k = 0; k < 4; k++)
{
if ('k'th queen is at i,j)
{
if (player 1's queen)
{
cout << "# ";
}
else if (player 2's queen)
{
cout << "O ";
}
blankflag = 1;
}
}
if (arrow at i,j and no queen)
{
cout << "X";
blankflag = 1;
}
}
if (blankflag)
{
cout << " |";
}
else
{
cout << " |";
}
cout << "\n ------------------------------------------------- ";
}
cout << " \n a b c d e";
The arrow is another mechanic. Anyways as arrows are shot and game progresses randomly the lowest and second lowest rows get shifted when i redraw the board. Anyone has a more elegant grid solution? I just want to draw a X or a # or a O depending on my game state(which is built)