Thanks Dr i really appreciate your time and help
.
although your reply was very helpful but im really confused , and got more questions
First
i think im rolling in circle without or like im taking a lot of time in this project although its easy except some bugs ,and im kinda approaching dead line so i need to build a working game as quickly as i can and then improve it if there is a time ,so i hope if there is any simple solution for this instead of lost into hard codes and reaching deadline .
but i can't deny the benefits i gained and gaining here ,and im making really use of it.
Second
questions about code (in comments) :
enum GameState {NOT_PLAYING, PLAYER_ONE_TURN, PLAYER_TWO_TURN};
...
GameState gameState;
while(window.isOpen()){
...
if (event.type==Event::MouseButtonPressed && event.mouseButton.button==sf::Mouse::Left){
if (gameState==NOT_PLAYING){
start the game ...
drawing grid and Displaying texts and menu right?
}
else {
detect which line we have clicked in
i will do that with 2 functions :
void GridSetHLine(Grid& grid, int x, int y, bool b);
void GridSetVLine(Grid& grid, int x, int y, bool b);
right?
then update the lines
Draw the line with another color that shows to the user that he has clicked on right?
numLoops= calculate all the loops we've just closed
if (gameState==PLAYER_ONE_TURN) playerOneScore += numLoops;
else if (gameState==PLAYER_TWO_TURN) playerTwoScore += numLoops;
detect if the grid is full, and if so go into GAME_FINISHED mode and show who won
}
}
...
draw everything
to draw anything i will set bool variable and using if and else i will draw it
}
so am i getting it right till now?
for the other code :
i got that Grid is kinda grid of bool beside the grid it drawn to the user ,and we use it to determine which line the user has clicked on.
void GridSetEmpty(Grid& grid);
so this function set all the grid to False till user click on any line it comes the turn of this two functions :
bool GridHasHLine(Grid& grid, int x, int y);
bool GridHasVLine(Grid& grid, int x, int y);
im really confusing at this ,but i think its a mouse position (x,y) ,but i can't understand why checking if the mouse position is in the range of the grid ? ,and also returning x and y as here :
else {
return grid.hlines[x][y];
}
confusing me cuz it cant be mouse position or it will be returning a huge integer for a grid.
any way this 2 functions will return some values that this two functions will take :
void GridSetHLine(Grid& grid, int x, int y, bool b);
void GridSetVLine(Grid& grid, int x, int y, bool b);
so this 2 functions will set the clicked line to True till it comes to the logic of GAME_FINISHED mode
so i hope i get most of it right
,and thanks for your time agian Dr