(gradually) Rotate towards a point

Chat about anything not covered in these forums, but keep it civil!

Post » Thu Sep 02, 2010 12:25 pm

Hi,

I'm developing an Android game in Java, obviously. I would like to know how the devs did the rotate towards a point (gradually) function in Construct. Probably you used vector math, that's not a problem.

EDIT: Actually, I have a variable that stores an angle, calculated thanks to the angle formed by the inclination of two accelerometer axis (X & Y):

resultingAngle = (float) Math.toDegrees(Math.atan2(accelerometerActualX, accelerometerActualY));

So, my car should gradually turn CW or CCW towards that angle.

Thanks
B
2
S
1
G
3
Posts: 193
Reputation: 1,486

Post » Thu Sep 02, 2010 12:40 pm

Search for the word "rotate" on this page and you can see the actual source:

http://construct.svn.sourceforge.net/sv ... ctions.cpp
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Sep 02, 2010 12:51 pm

I was looking for this. Thank you!

[code:1zlty283]resultingAngle = (float) Math.toDegrees(Math.atan2(accelerometerActualX, accelerometerActualY));
angle = main.RotateTowards(angle, resultingAngle, 1 * speed);[/code:1zlty283]

It's just perfect.
B
2
S
1
G
3
Posts: 193
Reputation: 1,486


Return to Open Topic

Who is online

Users browsing this forum: No registered users and 4 guests