How can I get rounded numbers from calculations that returns digits after the decimal point? And all the numbers together will be the number that is divided from.
Some walk/run sprites are less or more.
Let's say I have 3 walk sprites for walking down.
1: Look down
2: walkanimation sprite
3: walkanimation sprite
The distance between each tile, let's say, is 16 pixels.
16 pixels divided by 3 sprites is 5.33333.
So if the player walks down, each animationsprite wil move 5.3333 pixels down. That will end up that the player is at 15.999 pixels when the walk animation is done.
That will become not nice if the player walks down many times.
So I want to dynamically get the steps length which end up at the number that is divided from.
In this example:
16 / 3
Total: 16 pixels walked