SpaceGame
SpaceGame copied to clipboard
lose accuracy with using float for timetick
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.