SFML community forums

Help => General => Topic started by: mitop on December 21, 2018, 03:50:23 pm

Title: SFML cicrle movement
Post 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);
Title: Re: SFML cicrle movement
Post by: NGM88 on December 22, 2018, 06:27:07 pm
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
Title: Re: SFML cicrle movement
Post by: Kanoha on December 23, 2018, 04:02:10 pm
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.
Title: Re: SFML cicrle movement
Post by: Tigre Pablito on December 24, 2018, 12:07:15 am
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)?