Refactoring movement functions for player and entities