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
1
answer
178
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
2
answers
257
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 ...
0
votes
2
answers
211
views
How can I make a reliable time-based object updating system?
So an object has a position, velocity, and is affected by gravity.
...
0
votes
1
answer
916
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....
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 ...
1
vote
6
answers
816
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 ...
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 ...
2
votes
1
answer
244
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 ...
8
votes
1
answer
5k
views
Why loss of floating point precision makes rendered objects vibrate?
I'm working on an open-world game. I noticed glitches when I move far away from the origin. The objects seem to be shaking or wiggle. Especially the z-fighting seems to wiggle. And the objects that ...
2
votes
2
answers
2k
views
Prevent tile layout gaps
I'm making a map viewer where you can specify where tiles go in a map and then see it on the screen, translate it, and zoom in and out.
Here's a picture showing the tiles used to make my example map
...
4
votes
0
answers
214
views
How can I render geometry represented in a 64-bit floating point environment?
In this video about Star Citizen, right at the 12:30 mark on the timeline you can see the player zooming in on a space station who's location is clearly out of the limit of 32-bit floating point ...
0
votes
2
answers
336
views
Float inaccuracy. libgdx only? java only? also why?
Hey all I have just come to notice that floats are not accurate even when they are explicitly set and unchanged. For example i have some basic code running and it is:
...
21
votes
3
answers
4k
views
Non-integer speed values - is there a cleaner way to do this?
Often I will want to use a speed value such as 2.5 for moving my character in a pixel-based game. Collision detection will generally be more difficult if I do that, though. So I end up doing something ...
0
votes
2
answers
240
views
Unity, positioning with ints instead of floats
I round my transform.position to the nearest integer at the end of every frame so it's never a decimal number. I would like to know if there's a way to make unity store the position in ints instead of ...
17
votes
1
answer
7k
views
In Unreal, what are the differences between C++'s float and FFloat32?
I have been trying to learn some deeper aspects of UE4 and while reading many examples codes and also the source base of the engine, I noticed that sometimes people (and the very source code) use the ...
1
vote
0
answers
620
views
Handle floating point precision errors in collision detection and resolution
I am experimenting with a continuous collision detection and response of points on a tile map.
This are my results for now:
I did this by shooting a ray (red line) from the current position (red ...
6
votes
1
answer
2k
views
How do I avoid floating point indeterminism when implementing lockstep?
I am working on a multiplayer RTS game in Java. It uses lockstep for networking, which requires that both computers can deterministically.
These are the 2 closest/more viable approaches I could come ...
1
vote
1
answer
1k
views
WebGL half float equivelant?
I'm trying to find a half float for the purposes of doing math in a fragment shader, not trying to have a half float texture.
Is there an equivalent of the ...
2
votes
2
answers
1k
views
Getting around limitations posed by float in space game
I'm working on a procedurally generated game set in outer space. As in the real world, the game universe will be pretty much 99% empty, with planets/stars/solar systems etc... being very far apart.
...
17
votes
6
answers
15k
views
How do I generalise Bresenham's line algorithm to floating-point endpoints?
I'm trying to combine two things. I'm writing a game and I need to determine the grid squares lying on a line with the floating-point endpoints.
Moreover I need it to include all the grid squares it ...
2
votes
2
answers
2k
views
How can I simplify this code to compute the shortest rotation between two angles?
The following code will find the shortest rotation (in radians) (from pi to -pi) that I need to apply to from to leave me with to...
5
votes
4
answers
6k
views
How to reset the world in an infinite runner game to prevent an overflowing float?
Im following Mike Geig's 2D infinite runner tutorial. However, I'm seeing a potential problem of overflowing the float
How can I reset all objects and camera back again to the origin?
The approach I'...
5
votes
1
answer
1k
views
Deterministic calculation in JavaScript [closed]
I want to create a multiplayer game with HTML/JavaScript and only send user input between players. I read some articles for C++, saying that I could not expect floating point to get the same results ...
0
votes
1
answer
299
views
XNA Float values don't work as parameter
With the Microsoft XNA Framework I can change the color of a tinted texture by changing it's integer values like so:
...
0
votes
1
answer
709
views
Issues calculating frame independent movement
I'm developing a Breakout style game in C++ using SDL. The problem so far is that the ball slows down and speeds up for no particular reason.
The slowdowns usually last a few seconds.
EDIT : When ...