I have a little code here that isn't working quite the way I think it should...
Note that this is a rough draft simply used for testing, but the basic principle with speed/throttle will be the same. The velocity application is just a quick move command rather than the more complicated one I'll actually end up using.
Note that all values except throttle are declared with a # (throttle only needs to be a whole number), and acceleration is 0.1 for this test.
Basically, when I used something similar in an older Basic language I worked with, it did great, but here I have a problem...instead of landing correctly on the actual throttle value, it ends up some funky value like say, if the throttle is 5, it will be 4.9999 or something like that (hard to see, it jitters too much for an accurate reading on my test display). At 0, it ends up with some really strange value that is actually still moving, at considerable speed in fact (slightly less than 1 I'd guess, but certainly not stopped. Sometimes it goes negative as well moving the ship backwards).
Any way I can ensure the speed stops ON the throttle value, instead of a few decimal places away from it?
Sorry, I forgot the code box value, haven't used the forums in a while...
Note that this is a rough draft simply used for testing, but the basic principle with speed/throttle will be the same. The velocity application is just a quick move command rather than the more complicated one I'll actually end up using.
Note that all values except throttle are declared with a # (throttle only needs to be a whole number), and acceleration is 0.1 for this test.
If KeyDown(13) Then If s\Throttle < s\MaxSpeed Then s\Throttle = s\Throttle + 1 EndIf ElseIf KeyDown(12) Then If s\Throttle > 0 Then s\Throttle = s\Throttle - 1 EndIf EndIf If s\CurrentSpeed < s\Throttle Then s\CurrentSpeed = s\CurrentSpeed + s\Acceleration ElseIf s\CurrentSpeed > s\Throttle Then s\CurrentSpeed = s\CurrentSpeed - s\Acceleration EndIf MoveEntity(s\Entity,0,0,s\CurrentSpeed)
Basically, when I used something similar in an older Basic language I worked with, it did great, but here I have a problem...instead of landing correctly on the actual throttle value, it ends up some funky value like say, if the throttle is 5, it will be 4.9999 or something like that (hard to see, it jitters too much for an accurate reading on my test display). At 0, it ends up with some really strange value that is actually still moving, at considerable speed in fact (slightly less than 1 I'd guess, but certainly not stopped. Sometimes it goes negative as well moving the ship backwards).
Any way I can ensure the speed stops ON the throttle value, instead of a few decimal places away from it?
Sorry, I forgot the code box value, haven't used the forums in a while...