Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How do I my player move its body to the cursor?  (Read 1574 times)

0 Members and 1 Guest are viewing this topic.

huhfhewfoiwefi

  • Newbie
  • *
  • Posts: 1
    • View Profile
How do I my player move its body to the cursor?
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9994
    • View Profile
    • development blog
    • Email
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
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/