# float coordinate problem

This topic is 3861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im working on moving a player in a 2d rpg. The player has integral x and y coordinates pertaining to a tile on the screen. The problem has to do with the animation of moving the player. The animation moves the player a float value of (.25 tiles) 4 times within .3 seconds to make the player look like it is moving rather than 'hopping' between tiles. Im pretty sure the problem has to do with a negetive float becuase I can move the player down and right fine. I read somewhere the float range is 3.45E +/- 38, which would not include negetives. I need the decimal for incremental movements, but also need them to be negetive to move the player up and left. Any help is appreciated. Jacob

##### Share on other sites
Quote:
 Original post by AKofSpadesIm working on moving a player in a 2d rpg. The player has integral x and y coordinates pertaining to a tile on the screen. The problem has to do with the animation of moving the player. The animation moves the player a float value of (.25 tiles) 4 times within .3 seconds to make the player look like it is moving rather than 'hopping' between tiles. Im pretty sure the problem has to do with a negetive float becuase I can move the player down and right fine. I read somewhere the float range is 3.45E +/- 38, which would not include negetives. I need the decimal for incremental movements, but also need them to be negetive to move the player up and left. Any help is appreciated.Jacob

Normal floats can most definitely be negative, that's not your problem. Post the code where you try to move/animate the player so we can get a better idea of what's going on. Also, make sure you're not doing something like this:
unsigned int current = 4;unsigned int next = 3;float difference = static_cast<float>(next - current);
The point here is that an unsigned value subtracted from a smaller unsigned value will result in a very very large value.

Anyway, post the pertinent code between [source] and [/source] tags to make it pretty and scrollable.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 11
• 15
• 11
• 11
• ### Forum Statistics

• Total Topics
634149
• Total Posts
3015834
×