Skip to main content
gamedev.net
🔒 Locked

float coordinate problem

Started by AKofSpades Jun 29, 2008 at 1:56 PM 0 replies 850+ views
Original Post
AKofSpades
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
jouley
jouley
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.