I'm currently very new to XNA, and I'm trying to get a grasp on movement. Currently, I have a function that checks for keypresses, and moves my character from point A to point B instantly:
private KeyboardState currentKeyboardState; private KeyboardState previousKeyboardState; ... public void CaptureKeyboardInput() { currentKeyboardState = Keyboard.GetState(); // Move the character's sprite to the left on the screen. The movement // distance is determined based on the scale of the sprite texture. if (currentKeyboardState.IsKeyDown(Keys.A) && previousKeyboardState.IsKeyUp(Keys.A)) { Position += new Vector2(-Scale.X, 0); } // Move the character's sprite to the right on the screen. The movement // distance is determined based on the scale of the sprite texture. if (currentKeyboardState.IsKeyDown(Keys.D) && previousKeyboardState.IsKeyUp(Keys.D)) { Position += new Vector2(Scale.X, 0); } // Move the character's sprite upwards on the screen. The movement // distance is determined based on the scale of the sprite texture. if (currentKeyboardState.IsKeyDown(Keys.W) && previousKeyboardState.IsKeyUp(Keys.W)) { Position += new Vector2(0, -Scale.Y); } // Move the character's sprite downwards on the screen. The movement // distance is determined based on the scale of the sprite texture. if(currentKeyboardState.IsKeyDown(Keys.S) && previousKeyboardState.IsKeyUp(Keys.S)) { Position += new Vector2(0, Scale.Y); } previousKeyboardState = currentKeyboardState; } While this works, it looks very unclean, and feels unnatural as well. Ideally, I'd like to move it from point A to B at a certain speed. I've already looked around, and I've found this question, but I couldn't figure out how to implement it correctly. How can I implement smooth movement from point A to B in my tile-based game with what I have?