But in applying it I take the bum-rush-it-head-on approach which never, ever, ever works, and it means I spend more time sitting here at my computer staring at code than I ever see results.
Shoot me in the face |
Why? I don't know! Its a feature I wish to implement, but it's not critical! Basically I'm just trying to, when I have a velocity in a given direction, just simply rotate that velocity by a given number of radians. Yes, yes, trigonometry has come back to haunt you.
I do this by reversing the process of building a triangle. I start with a given number of radians and I do the following:
I add the number of radians that we are called to rotate
I make sure that our new radian degree doesn't exceed the bounds of 2 Pi, or is lower than 0 and assign it to a temporary variable known as Quadrant
(remember you unit circles, everybody? If not, Google it! You may learn something!)
I further find the specific radian degree within the boundaries of 0 to Pi / 2 (or 90 degrees) and then take the Sine and Cosine of that radian value (which gives me an X length (Cosine) and a Y length (Sine) with which to build a new triangle)
I then check which quadrant my variable Quadrant is a part of (Is this original radian in Quadrant I, II, III or IV of a regular graph?)
THEN it should be as simple as making my X length an Y length positive or negative depending which Quadrant the original radian value was in.
(Quadrant one has positive X and positive Y values only, Quadrant two has negative X and positive Y values only, etc.)
BUT for some reason it only gets my enemies to start turning in the correct direction when they are pointing to an object in Quadrant I or Quadrant IV (4)
No, apparently I got that brain. Poop. |
Sooooo... now I'm stuck, and frustrated, and it's past my bedtime yet again. And I have reading due for tomorrow. It's just unbelivably frustrating how I can spend my whole day programming and end at an impasse. It's like going to bed angry at your spouse, or when they make you sleep on the couch. This stupid little thing is going to bother me long into the night. And the crappy thing: It's been done 100x before in all manner of games!
I'm just too stubborn or afraid or proud to look it up on the internet.
AOHPOIWOEIHGAPOIHGOPIH! |
Not that I would know, or anything.. |
Fantastic.
-Kev
GENERIC F-BOMB JOKE |
We're gonna need a bigger- |
No comments:
Post a Comment