Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
178 views

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 ...
Sad Robot's user avatar
0 votes
2 answers
257 views

The game development library SFML has a Vector2 class template (and a Vector3 for that matter), which can use any arithmetic ...
JensB's user avatar
  • 157
0 votes
2 answers
211 views

So an object has a position, velocity, and is affected by gravity. ...
CPlus's user avatar
  • 153
0 votes
1 answer
916 views

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....
philB's user avatar
  • 331
6 votes
3 answers
4k views

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 ...
Nairou's user avatar
  • 634
1 vote
6 answers
816 views

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 ...
matronator's user avatar
52 votes
6 answers
19k views

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 ...
jvn91173's user avatar
  • 624
2 votes
1 answer
244 views

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 ...
Jacob Gunther's user avatar
8 votes
1 answer
5k views

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 ...
Newline's user avatar
  • 193
2 votes
2 answers
2k views

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 ...
Ryan1729's user avatar
  • 744
4 votes
0 answers
214 views

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 ...
Allahjane's user avatar
  • 729
0 votes
2 answers
336 views

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: ...
Big T Larrity's user avatar
21 votes
3 answers
4k views

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 ...
Accumulator's user avatar
0 votes
2 answers
240 views

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 ...
user avatar
17 votes
1 answer
7k views

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 ...
Kim Shutter's user avatar
1 vote
0 answers
620 views

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 ...
Michael's user avatar
  • 111
6 votes
1 answer
2k views

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 ...
Daniel's user avatar
  • 61
1 vote
1 answer
1k views

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 ...
Alan Wolfe's user avatar
  • 2,373
2 votes
2 answers
1k views

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. ...
Entity's user avatar
  • 601
17 votes
6 answers
15k views

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 ...
SmartK8's user avatar
  • 634
2 votes
2 answers
2k views

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...
t123's user avatar
  • 723
5 votes
4 answers
6k views

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'...
Michael Buen's user avatar
5 votes
1 answer
1k views

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 ...
cnubidu's user avatar
  • 51
0 votes
1 answer
299 views

With the Microsoft XNA Framework I can change the color of a tinted texture by changing it's integer values like so: ...
Anthonʎ's user avatar
0 votes
1 answer
709 views

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 ...
olevegard's user avatar
  • 172