Original Post
Hello people! I've been reading the forums for like 4 years and I could find answers for my previous doubts without posting threads. But about this time-based stuff I couldn't go through and I need your help. This is it. I am doing a SDL 2D game and I'm using delta time for the movement, and it works fine, but its a little annoyingly choppy. My game is running at 60fps and the delta time i get is around 0.001f and 0.003f. I wonder if the problem is that this delta time is a float, and the object position and speed are integers. SDL_Rect also uses Sint16 for its x & y coordinates, and the result of the movement calc is a float which is cast to an int before being assigned to the SDL_Rect. The only thing I see is that there might be a loss of precision here causing the choppy effect. The direction is either 1 or -1; positionX += (int) (speedX * deltaTime) * directionX; positionY += (int) (speedY * deltaTime) * directionY; Do you guys know a way to do time-based movement without using float in the calc? What do you recommend for a smooth time-based movement with SDL? Thanks in advance.