Trig and the infamous "45 degree angle bug"
I think I have the bug solved, but I can't come up with the actual
math... So I can't find out for sure.
|\
| \ Total speed
YV | \
| \
|________\ <--- Need this angle
XV
So I need some *FAST* functions to find the angle given the x and y
lengths (XV and YV), and a function to return XV and YV given speed and
angle.
Why do I need this stuff, exactly? I know the ship is going too fast, so
I need to slow it down. The old method just checks to see if the XV is
too fast, slow it down if necessary, then check the YV. This works fine
unless XV and YV aren't more than the maximum speed, but the hypertense
of the triangle with XV and YV is too fast, then the ship goes to fast.
If XV and YV are maxed out, you go at a 45 degree angle, and faster than
you should. This is a common bug with many games, but in some, it doesn't
matter. With the new weapons I am trying to put into Vector, the bug is
causing you to run into your own shots and blow yourself up if you are
going faster than you should. Here is what I am trying to do:
The ship is going too fast. (sqrt((xv*xv)+(yv*yv))=speed) I need to slow
it down. I get the angle that the ship is trying to go, then slow that
down. (Set it to max, which is less than what it is trying to go) Then, I
convert the angle it wants to go to X and Y velocities. Basically, I need
to convert to polar form (velocity and angle), but don't need velocity,
already have it, then I have the angle the ship is *TRYING* to go. By
slowing the velocity to the max, then converting polar form (velocity and
angle) to rectangular form (X and Y), should fix this bug......
Hope I explained this well enough. These routines need to be fast in
order to actually use, but if they work, I can at least find out if the
algorithm works. I can't test it unless I have them.... If you see
something wrong with my math, and can still fix this bug, then I'd like
to hear it.
Thanks
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
|
Not Categorized, Please Help
|
|