SFML community forums
Help => General => Topic started by: mitop on December 21, 2018, 03:50:23 pm
-
Does anybody know how to make something like circle movement in SFML? I would like to make some game with tank as main character. Its moveing only forward or backward and rotate. So how can i apply movement to degree? Sorry for my languga mistakes and tell me if i wrote something incorrectly! Thanks for any respond.
Okay i know for everybody that wants to know:
body.move( -sin(body.getRotation()*3.14159265 / 180)*-3, -cos(body.getRotation()*3.14159265 / 180) * 3);
-
body.move( -sin(body.getRotation()*3.14159265 / 180)*-3, -cos(body.getRotation()*3.14159265 / 180) * 3);
I don't know what that is but my advice is to read the official tutorials such as:
https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php
-
body.move( -sin(body.getRotation()*3.14159265 / 180)*-3, -cos(body.getRotation()*3.14159265 / 180) * 3);
I don't know what that is but my advice is to read the official tutorials such as:
https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php
Mitop's solution is perfect for the problem he wants to solve. The graphics tutorial page don't show how to do it, simply because the issue isn't related to SFML, but to general mathematics.
-
Hi Guys
I have one doubt: shouldn't the rotation attribute be updated after that formula? Or it is automatically?
body.move( -sin(body.getRotation()*3.14159265 / 180)*-3, -cos(body.getRotation()*3.14159265 / 180) * 3);
If you don't do this
body.setRotation(body.getRotation() + rotation);
wouldn't it go like by a line (constant)?