This not so simple design allows you to put a real physics simulator in your game, which allows you to add movements with progressive acceleration and deceleration . This physics simulator lets you customize every single aspect of it (increment of speed, drag...). The code may be long because it's made so it can withstand opposite commands and / or commands within a short timespan.
Project made by a student for abt 3 hours (trial and error). Would be happy if you left a comment or whatever, it always helps :)