keep track of deltaTicks will endup overflowing? #1245
Replies: 2 comments
-
Unless you want to build a real-time online server with 100% uptime and an elapsed delta time that doesn't reset during an entire year then yeah go ahead and just use |
Beta Was this translation helpful? Give feedback.
-
Cool, thanks for the explanation. Make sense. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was wondering if it would be okey to keep track of the game elapsed time using the deltaTicks. For instance, say we have this pseudo code:
`
void Foo::init()
{
float timePassed = 0.0;
}
void Foo::update(float delta)
{
this timePassed += delta;
//.....more
}
`
A float variable does overflow with 3.40282e+038. I haven't done the exact calculation, but that means that it would take almost a year of this loop to be running nonstop to overflow.
Being new to game development I was wondering if it is a bad practice to do that or if it is okey, considering that it is very unlikely to have a game loop running a year (plus we could reset timePassed if a new level loads, the player dies, etc...) .
I know it might be a very basic question, but I am new to game dev and I would like to know what experienced game devs think.
Thanks,
R
Beta Was this translation helpful? Give feedback.
All reactions