Questions tagged [floating-point]
Floating point numbers are approximations of real numbers that use a form of scientific notation to store significant figures and an exponent. Use this tag for questions that pertain to the use of floating point numbers in games.
61 questions
0
votes
0
answers
123
views
How can I improve vector collision algorithm?
I'm making a game (shocker) in pygame and had issues with tile-based collision detection. There are 5 different non-empty tile types (pictured below) which can be rotated in increments of 90 degrees ...
0
votes
0
answers
100
views
How to make calculating the inverse matrix more robust?
When I calculated the inverse matrix, I found that the error in using the float data type would cause the inverse matrix calculation error. Is there any good solution?
...
0
votes
2
answers
216
views
Is there a logical reason for SFML's Vector2 being templated?
The game development library SFML has a Vector2 class template (and a Vector3 for that matter), which can use any arithmetic ...
1
vote
1
answer
453
views
Godot Velocity: Invalid type in utility function "lerp", cannot convert arg 2 from Vector2 to float on line 40
I'm trying to solve a lerp problem on my velocity, searched some stuff here and there, but found nothing that solved it. Can you help me?
...
0
votes
2
answers
188
views
How can I make a reliable time-based object updating system?
So an object has a position, velocity, and is affected by gravity.
...
1
vote
2
answers
193
views
What dynamic range of numbers do games typically use?
Most of the numeric quantities used in games (aside from integers for counting or indexing objects) are single-precision floating point. This is IEEE format, which allows for numbers as big as 1e38 ...
0
votes
1
answer
879
views
24bit float to RGB
There's solutions to convert float to RGBA but I would like to encode a float depth value in RGB format and save the three components in three separated unused alpha channels and recompose when needed....
0
votes
1
answer
2k
views
Dealing with Floating Point precision in a Minecraft-like game
As far as I know, you can walk for 30 million meters in either direction in Minecraft to reach the end of the world.
My question is, how does Minecraft handle loss of precision when dealing with ...
6
votes
3
answers
4k
views
Convert integer to float while also dividing down the scale, without data loss
I'm working on a game, and my intent is to avoid use of floating point for unit positions. To that end, I'm using 32-bit integers for all positions, with a millimeter scale.
However, for rendering, I ...
3
votes
2
answers
4k
views
Mathf.Approximately: should I use it & for what cases?
For comparing floats they recommend using Mathf.Approximately
At the same time, they don't use it, for example, for comparing types such as vectors.
From Vector3....
1
vote
6
answers
751
views
How to deal with players having too much money (or any large numbers)?
I'm working on a browser MMORPG in PHP and MySQL and today got a bug report about int32 overflow, due to the player having too much money. When I was designing the core system, I completely forgot ...
3
votes
0
answers
185
views
Quake 1: frame timer
If you check Quake 1 source code (sys_linux.c), you can see something like this:
...
52
votes
6
answers
19k
views
How can I perform a deterministic physics simulation?
I'm creating a physics game involving rigid bodies in which players move pieces and parts to solve a puzzle/map. A hugely important aspect of the game is that when players start a simulation, it runs ...
0
votes
1
answer
239
views
How can I avoid the precision loss when recentering objects on open terrain?
For a better context this question is related to this one:
What's the largest "relative" level I can make using float?
When the player is moving too far away from the center, all the ...
2
votes
1
answer
223
views
How much slower is it to draw on "half pixels"?
I've noticed that games like Diep.io are using floating decimal points for thin stroke lines on the grid. I have even tried this myself, by adding 0.5 to all of the ...