Wednesday, May 11, 2011

Gosh Dang it.

This is how I feel when it comes to math.  I can't stand the stuff sometimes.  I was, admittedly, incredibly blessed to have my mom basically re-learn math in order to teach it to me, so I understand the fundamentals and can pass most math classes with flying colors.

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
That is never ever, ever, ever a good approach to math and/or programming (basically any kind of logic thinking) but I never seem to learn my #&@% lesson.  And I've been through this more times than I can count.  Basically right now I'm doing something that is, AGAIN NEARLY COMPLETELY IRRELEVANT TO THE OVERALL FUNCTIONING OF THE GAME!

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!
Yes, I know what you are all thinking of me right now: A hopeless basket-case of a nerd.  Yeah, well, girls and having a life are overrated.

Not that I would know, or anything..
Now I shall sleep fitfully and frustrated.
Fantastic.

-Kev
GENERIC F-BOMB JOKE
We're gonna need a bigger-

No comments:

Post a Comment