Gradually accelerate sprite on key pressed; gradually decelerate on key released
I've been trying to figure out how I can gradually accelerate a sprite on key pressed and then once the key is released, gradually slow down to a stop, much like the ship in Asteroids . I would like to do this without any game engine if possible. I searched this up on SO and found related questions, but they did not answer my question exactly in my opinion. What I've thought of so far is: //while the key is being pressed //move by increasing y value //but continue to increase the amount y increases by as you hold this down, //until it reaches certain maxSpeed //when the key is released,