Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Window
»
How do I my player move its body to the cursor?
Print
Pages: [
1
]
Author
Topic: How do I my player move its body to the cursor? (Read 6525 times)
0 Members and 1 Guest are viewing this topic.
huhfhewfoiwefi
Newbie
Posts: 1
How do I my player move its body to the cursor?
«
on:
October 12, 2021, 03:20:55 pm »
Video example:
Sorry if this is the wrong category I am new on the forum.
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11030
Re: How do I my player move its body to the cursor?
«
Reply #1 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
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
Print
Pages: [
1
]
SFML community forums
»
Help
»
Window
»
How do I my player move its body to the cursor?