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 5474 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: 10815
    • 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
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything