I started counting from 0 and it works now. The problem I am facing now is that I render when when the square in the XnO table is empty and when is the turn of player 1 but when is the turn of player 2 what was rendered befor disapears.. The problem is that Xs are rendered only when is player1 turn and Os only when is player2 turn. Maybe i should add a new condition?
//getting input if (mousex >= 140 && mousex <= 250 && mousey <= 200 && mousey >= 115 && hge->Input_GetKey() == HGEK_LBUTTON && table1 == true) { table1x = 190; table1y = 150; table1 = false; matrix[0][0] = 1; turn++; } if (mousex >= 250 && mousex <= 375 && mousey <= 200 && mousey >= 115 && hge->Input_GetKey() == HGEK_LBUTTON && table2 == true) { table2x = 315; table2y = 150; table2 = false; matrix[0][1] = 1; turn++; } ......... //rendering if (table1 == false && player1 == true) x_spr->Render(table1x, table1y); else if (table1 == false && player2 == true) o_spr->Render(table1x, table1y); if (table2 == false && player1 == true) x_spr->Render(table2x, table2y); else if (table2 == false && player2 == true) o_spr->Render(table2x, table2y);
Your render should work a bit differently. You say you are using 1, 0, and -1, so do this for your render:
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
// Draw XnO[i][j]; -- Here you can do if statements for determining whether to draw an X, draw an O, or just not draw anything
}
}
EDIT: Why do you have table1x, table1y, table2x, table2y? Scratch that. It's late....