Re: Trig and the infamous

new topic     » topic index » view thread      » older message » newer message

>Do you mean to check the actual speed and return that value?
>I've added a few lines of code into vector.ex that I think fixed the
>problem (the same idea that I mailed you).  I've realized that the
>percent multiplyer is very important.  If it is too small you can go
>over the max.  If it is too large you can't reach the max.  The only
>value that is perfect is .9090909.  I have no idea why it's such a
>weird repeating number and no doubt .9090909090909090909 would be even
>better but with all the rounding errors .9090909 is all that is
neccesary
>to reach exactly 5 eventually.  If you want the exact (tested) code then
>here it is (this also has 2 ways to show the speed on the screen so
>you know (exactly) how fast your going at any given time):

Hmm, I found that .9 made you go a little to fast, (About 0.05 too much),
and that 4.5 was the limit... I think...

The algorithm Pete sent me works perfectly, never goes over 5, never
drops under 5. (Unless you turn enough to slow you down, in any case, it
works :) I have no idea what a "normalize the vector idea" is, but it
works, so I'm happy.

>there's only one small problem with this: no matter what you change
>player_top_speed to, your speed will never get over 5.  I don't know
>how to explain this unless my code is conflicting with some of yours.

That would cause problems with the missile code, which goes at 11 max..

>>       |\
>>       |  \  Total speed
>>    YV |    \
>>       |      \
>>       |________\ <--- Need this angle
>>
>>          XV
>
>            ^
>            |
>Nice diagram :)
>I thought the angle was what ever you plugged into the
>rotate function.

I don't understand you here...

>>Why do I need this stuff, exactly? I know the ship is going too fast,
>>so I need to slow it down.
>
>So if you had the code to take care of the speed stuff you wouldn't
>really need to know the angle? or would you?

According to Pete's solution, I don't.... Hmmmmm. I still may need the
angle, but (thanks Wally!) the arctan(xv/yv) should do that. I still want
the angle stuff so I can test ahead of the enemy ships so they can avoid
collisions with the rocks. Then I can make the rocks have the ability to
smash the enemy ships and make everybody happy... ;)

>>unless XV and YV aren't more than the maximum speed, but the
>hypertense...
>
>That's "hypotenuse" I think.  It doesn't have an "r" in it

Okay, just checked, you're right. I still think "Hypertense" sounds
better, though.. :) I've been misreading it for forever.... :)

>>you should. This is a common bug with many games, but in some, it
>>doesn't matter.
>
>I think it matters in all games.  It's just that most games developers
>think that game players for the most part are rather stupid... well
>maybe we are but I don't like my intelegence insulted so I think it is
>good when a programmer is concerned with this issue

:)
I was mostly concerned with the issue of you running into your own shots,
but the bug had always bothered me. It killed the "perfection" of it
all.. ;) If you look closely at some games, you can see the effects of
improper maximum speed handling. (I've seen it in MechWarrior II. When
you move sideways and forward at once in GoldenEye 007 for N64, or any
first person shooter, you'll always go faster. [Tip: Face where you want
to go, turn 45 degrees, then go forward and sidestep (strafe) at the same
time, while running if you can, you'll get there faster]. Defender also
has the problem. (Thrust while moving up or down.) OidZone has the
problem. ;) Asteroids cleverly avoided the problem without even trying...
;)

I suppose the only games where the bug is even worried about is racing
games. The physics have to be 100% correct otherwise you could cheat....

>I think you're making this harder than it has to be, but if your idea
>runs faster than mine, go for it.

I thought of it last night, it seemed complex but I figured the solution
must be complex for so many games to completely ignore it... But it turns
out it wasn't.. I have no idea why it works yet, but it doesn't use
enough multiplying or lines of code to be "complex"... ;)

>Another thing:  you probably will want to use this algorithm on all
>moving objects in the game eventually so my code will need to be
>modified and most likely put into a function or something.

I just used Pete's way (only 5 lines) on the three objects that needed
it: Player, enemies, and missiles. Nothing else has thrusters so don't
need to worry about it.

>Well, I hope this works,

I'll check to see how well it works.... I already have a solution, but I
can still check out how it performs..

P.S., try Pete's way and printout the actual speed. Pretty impressive,
how it stays perfectly stable.. (To 8 decimal precision points, at
least...)


P.P.S: If anybody else has read this far, I have a new version of Vector
finished, I've sent the details to those who responded to the last
release, but if there is anybody else interested, just ask.

_____________________________________________________________________
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]

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu