SFML community forums

Help => Window => Topic started by: huhfhewfoiwefi on October 12, 2021, 03:20:55 pm

Title: How do I my player move its body to the cursor?
Post by: huhfhewfoiwefi on October 12, 2021, 03:20:55 pm
Video example: https://www.youtube.com/watch?v=ilBknCcZvZ4

Sorry if this is the wrong category I am new on the forum.
Title: Re: How do I my player move its body to the cursor?
Post by: eXpl0it3r on October 12, 2021, 04:00:53 pm
You can use atan() to calculate the needed rotation.

I've created once two examples, one for a shape and one for a vertex array.

https://github.com/eXpl0it3r/Examples/blob/master/SFML/RotatingTriangle.cpp
https://github.com/eXpl0it3r/Examples/blob/master/SFML/RotatingVertices.cpp