On SFML documentation I see that position of Sprites and shapes is... float. Why? Is it linked with sf::View, which bounds are float too?
Links to documentation:
sf::Transformable
sf::View
sf::RenderWindow
You need floating points in order to animate you sprites correctly. Imagine a position at x=1, and you increase the position based on your delta time to 1.1. It would take 10 frames to move your sprite to x=2 (next pixel). Using integers x would be rounded to 1, and you won't move at all.
Besides that, in order to render stuff, you have to calculate the transform matrix (using floats), so you had to convert to floats sooner or later anyways. This is how graphics API's work internally, SFML simply wraps everything up so you only have to worry with screen coordinates (pixels, in that case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With