PDA

View Full Version : 2D movement algorithms



hellox
04-17-2003, 03:04 PM
Hi =) does anyone have a hint on making a smooth 2D movement of a square moving with keyboard control (holding key to move, not continous movement) in a full screen animation? no matter how small i put the movement unit, it always looks kinda false.

Thanks for any help

JML from PT

Deiussum
04-18-2003, 04:24 AM
I'm assuming with each key event, you are moving a certain distance?

Instead try to have a boolean flag for moving that gets set to true on the key down, and false on the key up. Then in the animation loop if it's true, you move based on the time that's elapsed since the last animation frame.