I am trying to right click and place a flag on the indicated space. What I'm getting when I print the x and y coordinates is nothing, but when I hold down the click and move around the mouse it then shows the position. Any help is appreciated.
if (Mouse::isButtonPressed(Mouse::Right))
{
Vector2i mousePosition = Mouse::getPosition(window);
// for (int i = 0;i < boardObject.boardOne.size(); i++)
// {
// if (boardObject.boardOne[i].)
//}
Sprite flag(Flag);
flag.setPosition((float)mousePosition.x, (float)(mousePosition.y));
int x = mousePosition.x / 32;
int y = mousePosition.y / 32;
cout << x << endl;
cout << y << endl;
boardObject.boardOne[x][y].flagBool = true;
window.draw(flag);
}
if (Mouse::isButtonPressed(Mouse::Left))
{
for (int i = 0;i < 25;i++)
{
for (int j = 0;j < 16;j++)
{
Vector2i mousePosition = Mouse::getPosition(window);
Sprite revealedTile(tileRevealed);
revealedTile.setPosition((float)mousePosition.x, (float)(mousePosition.y));
window.draw(revealedTile);
}
}
}
window.display();
Comments
Post a Comment