Smooth character movement (theory)

Started by
0 comments, last by d00fus 14 years, 4 months ago
Hi guys, Thought this would be a bit of a n00b question. I'm making a game on a Blackberry smartphone (Java). So far I have a sprite and a background. The sprite can be moved around (4 directions) using specified keys on the keypad (by adding/subtracting to the pixel coordinates of the current sprite location on refresh). What I was wondering is how I can make the character move 'naturally' or 'smoothly' from one coordinate to another. For example, I'm adding 2 to the y-coord int. But the character jumps to the next coordinate. So the movement is 'blocky' or 'jittery'. What can I do to combat this so the sprite moves smoothly like Mario or Link? Cheers in advance :)
Advertisement
Generally you'll do this by specifying positions and movements using either floating or fixed point numbers. These allow you to specify sub-pixel units, so for example, you can add 0.2 to the y-coord each frame, so every 5 frames it will move one pixel. I'm not familiar with the Blackberry hardware but you might find fixed point is much faster if it doesn't have floating point hardware.

This topic is closed to new replies.

Advertisement