EDIT : my problem has evolved, it is now described in post number 4 of the topic
Hi everyone,
I'm trying, with a few friends, to develop a Go game in C++ using the SFML. We are beginners (first time using a GUI) and our problem probably comes from the display of our pawns : we created a class pawn and an array of pawns that represents the game board (each intersection on the board has its own coordinates in pixels associated to a cell of that array). We are using the cells of our array as pawns and we're displaying their sprite if there is a click on an intersection. We're loading the texture in the sprite (each cell/pawn has a sprite because we created it as a member of the class pawn ) depending on whose turn it is (the pawn has a member that defines which player clicked on the board).
We know that our program is badly written, but I think (definitely not sure though) I know where the issue comes from, and I just don't know why it's buggued there.
I'll post where I believe our problem comes from, but if you guys need more, I can post the entire program (which isn't that beautiful).
Unfortunately we are French, so I apologize for the bad english and the reading issues you guys might encounter if I post the entire prog.
//[...]
window.clear(); //my window is called window
window.draw(s_fondEcran);//that's a wooden background
window.draw(s_goban9x9); //that's my plate
window.draw(texte1); //a text above the plate
window.draw(s_boutonPasser); //That's a button to pass the turn
for (int i=0; i<=8; i++) {
for (int j=0; j<=8; j++) {
if(plateau[i][j].get_joueur()==1) //j1 = black color
{
plateau[i][j].sprite.setTexture(t_pionNoir); //sets from texture loaded from black pawn earlier
window.draw(plateau[i][j].sprite);
}
else{
if(plateau[i][j].get_joueur()==2) //j2 = white color
{
plateau[i][j].sprite.setTexture(t_pionBlanc); //sets from texture loaded from white pawn earlier
window.draw(plateau[i][j].sprite);
}
}
}
}
} //End of the while (window.pollEvent(event))
window.display();
} //End of the while (window.isOpen())
return EXIT_SUCCESS;
} //end of my function
So I thought my double for would go through my array and display the sprite of the cell if this one is loaded with a texture depending on the player.
Instead it kinda displays whatever it wants whenever it wants, even deleting other sprites, and eventually the program crashes.
I think this is the display that buggs out because when we play the game on the terminal it works perfectly well (we display the game at the same time on the terminal and it does what it's supposed to do).
If it is something else that might cause the issue, please tell me.
Thanks for reading,
Fallows
PS : We set the sprites positions earlier, before the while(window.isOpen){} using this :
for (int i=0; i<=8; i++) {
for (int j=0; j<=8; j++) {
plateau[i][j].sprite.setPosition(234+(54*i), 134+(54*j));
plateau[i][j].sprite.setOrigin(10,10);
}
}