Im trying to create a block placement with snap to grid. Everything is working, and in my head this should update the position of the mouse relative to the window each frame
You need to call window.mapPixelToCoords()
to transform your pixel position to the coordinate system of your view.
sf::Vector2i pixel_pos = sf::Mouse::getPosition(window.mywindow);
sf::Vector2f coord_pos = window.mywindow.mapPixelToCoords(pixel_pos);
And as a general advice: Don't use public class members - mywindow
and playerSprite
should not be accessible from the outside.