adding event handling, refactoring the code for more logic and syncing platform speed with player speed