C++ gamedev: truncating float to int
Keep the location of the tank in float
s all the time. Alternatively, only let the tank rotate in increments of 45 degrees. Decide on whether your game will use approximate positions and headings or exact ones and stick to that decision all the way through.
How can I do to make the direction of the tank more accurate? To raise the speed or the value of deltaT are not options since it's about a tank, not a formula 1 :P
You should store your position values as float
s, even though they are ultimately used as int
s for on-screen positioning. That way, you won't lose the non-integer portion of your position. Just cast to int
right at the end when you do your drawing.