Reputation: 11
I made a view centered on the avatar of the player sprite, and after 3 days of brain storming all I've got is (basically) this:
xVeiwMouse = xWindowMouse - Playerx;//(new mouse coord) = (mouse coord relitive to window) - (playersprite coord)
yVeiwMouse = yWindowMosue - Playery;//same, but with y
which doesn't work.
I need the mouse's coordinates relative to a view, centered on the player.
Upvotes: 1
Views: 2348
Reputation: 2613
Something like this?
sf::Vector2f mouse_pos = window.mapPixelToCoords(sf::Mouse::getPosition(window));
sf::Vector2f relative = player.getPosition() - mouse_pos;
Check the official documentation and tutorials for further explanations on the used functions.
Upvotes: 2