returning angles in different ways
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
returning angles in different ways
ok I am making a code that requires self.angles_y.
self.angles_y is ranged between -180 and 180
how can i make it so that it has no range (ie it increases when you turn right, decrease when you turn left). using the -180 180 range or the 0 360 range causes problems. when your angle is 180 and it increases, it instantly becomes -180.
any help is appreciated
self.angles_y is ranged between -180 and 180
how can i make it so that it has no range (ie it increases when you turn right, decrease when you turn left). using the -180 180 range or the 0 360 range causes problems. when your angle is 180 and it increases, it instantly becomes -180.
any help is appreciated
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
you may need to consider quadrants and to possibly add 360 to one angle if you're comparing them.
otherwise, avoid the use of writeangle even in engine code. good luck with that...
otherwise, avoid the use of writeangle even in engine code. good luck with that...
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Not sure if this is what spike means but quadrants are what you get when you divide the circle into 4 parts, eg 0-90, 90-180 and so on. What quadrant is called what might differ on context so I won't mention that.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
- Spirit
- Posts: 1031
- Joined: Sat Nov 20, 2004 9:00 pm
Spirit wrote:Not sure if this is what spike means but quadrants are what you get when you divide the circle into 4 parts, eg 0-90, 90-180 and so on. What quadrant is called what might differ on context so I won't mention that.
i remember this in math class. thanks spirit.
So i guess there's no type of .movement vector but for turning? bummer...
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
diff = new - old;
if (diff > 180)
diff -= 360;
if (diff < -180)
diff += 360;
of course, if they do manage to do a 180 degree turn in the span of a single frame, your mod will think they're turning the other way around. If your framerate is 72fps+, that's not really a likely situation (unless they're using various rj/turn scripts).
if (diff > 180)
diff -= 360;
if (diff < -180)
diff += 360;
of course, if they do manage to do a 180 degree turn in the span of a single frame, your mod will think they're turning the other way around. If your framerate is 72fps+, that's not really a likely situation (unless they're using various rj/turn scripts).
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest