Jump to content
  • Advertisement
Sign in to follow this  
AKofSpades

float coordinate problem

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by AKofSpades
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

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!