It's not a problem that you're a beginner. But you need to offer more information on your problem. The code fragment you posted cannot be all of your code. How does the rest work? How do you move in your game? How do you apply gravity. What is the variable dist and where else is it used? What kind of game is it at all that you make.


Always learn from history, to be sure you make the same mistakes again...