Here is a code that could give you hints. Use W,A,S,D to move the character. This one uses the return, see how the GOSUB calls line 1000 at the beginning, the RETURN returns to the line after the GOSUB. So you can break up your code in tidier modules using that method.