Currently I'm working with this:
if (event.MouseButton.Button == 0)
{
for (int i = 0; i < blocks.size(); i++)
{
sf::Vector2f pos = blocks[i].GetPosition();
if (event.MouseButton.X >= pos.x && event.MouseButton.X < pos.x + 32 &&
event.MouseButton.Y >= pos.y && event.MouseButton.Y < pos.y + 32)
{
blocks.erase(blocks.begin() + i);
break;
}
}
}
Which works pretty well! However, whenever I alter the position of my "camera" view, of course it doesn't work anymore. Is there an offset I could apply to the condition to correct the problem?
Also, would it be better to check sprite.GetPosition().X and .Y instead of creating a Vector2f each time? Or is it not really too significant?
Thanks for any help.