Code doesn't just become sentient, so you can assume that something in the code is wrong. In order to figure out what is wrong, you first check with pen and paper, whether your math is correct.
If it is correct, then you go on and check whether all the values are correct. Is the mouse position what you expect it to be (is it relative to the window and is it in the world coordinates)? Is the player position as expected? Are the calculated values as expected?
If all the values are what you expect them to be, you can move on to checking whether the game logic makes sense. Does your code ensure that the player doesn't move at one point?
For checking values you can either use the debugger and its variable inspection functionality or use simple std::cout statements.
My guess would be right now, that you're not properly get the mouse position.