SpaceGame icon indicating copy to clipboard operation
SpaceGame copied to clipboard

lose accuracy with using float for timetick

Open liues1992 opened this issue 9 years ago • 0 comments

in the code

float HelloWorld::getTimeTick() {
    timeval time;
    gettimeofday(&time, NULL);
    unsigned long millisecs = (time.tv_sec * 1000) + (time.tv_usec / 1000);
    //the millisecs is always 13 demical digits long, however float only have at most 9 significant demical digits.
    return (float)millisecs;
}

As a result, there is only one asteroid spawned in a game.

liues1992 avatar Apr 23 '15 05:04 liues1992