@jonikorpi@mastodon.gamedev.place
Post #4168454
2026-07-06 09:30 UTC
Replies (3)
-
@sol_hsa@mastodon.gamedev.place 2026-07-06 09:37
@jonikorpi@mastodon.gamedev.place @TomF@mastodon.gamedev.place https://jet.ro/2006/08/07/neglected-art-of-fixed-point-arithmetic/
-
@TomF@mastodon.gamedev.place 2026-07-06 09:42
@jonikorpi@mastodon.gamedev.place Uuuuu... it's pretty close to that simple. You need to pick a scale that "1" means - millimeters or whatever. Stick it in a constant and you can change it later. Any time you read the fixed-point position of an object, subtract the fixed-point position of the camera. Do the subtraction also in integer. Then convert the int to float and multiply by the scale. That's the camera-relative position (e.g. in meters). The rest is just like normal.
-
@floooh@mastodon.gamedev.place 2026-07-06 10:03
@jonikorpi@mastodon.gamedev.place @TomF@mastodon.gamedev.place you really don't need much of a guide because it's exactly the same as regular integer math, just with an imaginary decimal point - think of "working" in meters, but with 3 fractional digits so that you actually have millimeter precision - that's fixed point math :)