ok i have just tried this
sf::Vector2i pos = sf::Mouse::getPosition(screen);
I print this out
std::cout << "X:" << v2.x << ".Y:" << v2.y << std::endl;
and i can get to a total of
X : 1024
Y : 768
now my game is about 4000 by 2000, all I want to try and do is get the mouse coordinates not from the window itself but from its actually position in the game world, so if i moved right by 1000, the
mouses position would be 2024. how can I achieve that?
its ok i have fixed it and it now works 100% cheers for all the help, i will post some code to help anyone else that needs it
each of my tiles is 32 by 32, and i have 75 columns and 150 rows.
my program window is 1024 by 768. I then create this tiny for loop to check where the mouse is and what to do
for(int i=0;i<blocks.size();i++)
{
int rowNum = (pos.x+player.pos.x-(496)) / 32;
int colNum = (pos.y+player.pos.y-(384)) / 32;
blocks.at((colNum*150)+rowNum).setBlockId(2);
}
the player.pos just replace the player with camera, my "camera" is always in the center, so we take away 496 (my camera has a width???
) and then 768/2 = 384, now the pos.x is this piece of code which is before the for loop
sf::Vector2i pos = sf::Mouse::getPosition(screen);
screen is my renderWindow.
now i then divide them by 32 as that is the width and height, if you have different width and height then just change the values. once done, we go through our vector and find which block we want to change and DING, done
this code will throw a error if it isnt touching a block but that can be easily fixed. hopefully this helps others.