I've been working on a map that uses a unique variant of the WASD movement system. To keep a long story short, it's based on a unit's facing angle and computing the related horizontal and vertical directional components to control x- and y-velocity.
Unfortunately, I've run into a seemingly insurmountable roadblock: fixed point (real) rounding.
For whatever reason, I can't seem to specify to what precision I want arithmetic operations to be performed, so everything keeps defaulting to essentially integer multiplication/division. A simple example would the division of two angles, specifically 60° and 90°. While this should obviously give me 2/3 as a result (or 0.66667), I get 1 instead -- rendering such calculations entirely useless.
The only method capable of performing less clunky arithmetic I've found thus far is the use of fixed variables (reals) in strings/text -- because I can specify a precision value (even if fixed point rounding sucks). This doesn't really seem to be a workable solution as far as I can tell, though, because all precision is lost when these strings/text variables are converted back to reals.
So, now that I'm pretty much out of ideas, I figured I'd turn here and see if you folks could point me in the right direction.
Hey, guys.
I've been working on a map that uses a unique variant of the WASD movement system. To keep a long story short, it's based on a unit's facing angle and computing the related horizontal and vertical directional components to control x- and y-velocity.
Unfortunately, I've run into a seemingly insurmountable roadblock: fixed point (real) rounding.
For whatever reason, I can't seem to specify to what precision I want arithmetic operations to be performed, so everything keeps defaulting to essentially integer multiplication/division. A simple example would the division of two angles, specifically 60° and 90°. While this should obviously give me 2/3 as a result (or 0.66667), I get 1 instead -- rendering such calculations entirely useless.
The only method capable of performing less clunky arithmetic I've found thus far is the use of fixed variables (reals) in strings/text -- because I can specify a precision value (even if fixed point rounding sucks). This doesn't really seem to be a workable solution as far as I can tell, though, because all precision is lost when these strings/text variables are converted back to reals.
So, now that I'm pretty much out of ideas, I figured I'd turn here and see if you folks could point me in the right direction.
What do you all think?
Thanks!
60.0/90.0 is 0.6665 for me ingame.
So your simple example is flawed. :(
Angles use (-180, 180]. Maybe that explains something in your "simple" example.
Text won't work as texts can't be reverted to strings. So you can't recover values from it. So strings or arrays of integers might work best.
You know, I feel sad and ashamed now.
I decided to take a break and walk away from the computer for a bit, so I shut down the editor and whatnot.
Things are working just fine after the reboot.
Sorry for wasting your time, I guess.
No problem.
The best problems are problems that vanish on a second look. :D