I have re-written your code for you the way that I would go about making a game.
You can see from my 'do-loop' that my main loop simply calls functions. I find it an easy way to work because you can see everything that the code needs to do within a loop and it is easy to see what to work on next.
It is perhaps not everyones favourite way to work but I find it much easier.
I have added a score system and a life remaining system to your code as well as a 'Game Over' message and the option to try again.
I have not put in any remarks to help you ... I thought you might like to work out what is happening on your own
... If you have any problems though please do not hesitate to ask and will help you.
sync on
sync rate 30
hide mouse
Global num1
Global num2
Global num3
Global TextHeight
global Score
Global Lives
Global Answer as string
Global LastInput as string
Global InputLength
Global AnswerLength
NewGame()
do
cls
DisplayProblem()
GetUserInput()
CheckAnswer()
CheckHeight()
sync
Loop
function DisplayProblem()
set cursor 0,0
Print "Lives: ",Lives," Score: ",Score
set cursor 0,TextHeight
print num1,"+",num2,"= ",Answer
inc TextHeight,2
endfunction
function GetUserInput()
I$ = inkey$()
if I$<>""
if I$ <> LastInput
LastInput = I$
inc InputLength,1
Answer = Answer + I$
LastInput = I$
endif
else
LastInput =""
endif
endfunction
function CheckAnswer()
if InputLength = AnswerLength
if val(Answer) = num3
inc Score
NewProblem()
else
I$ = ""
Answer = ""
InputLength = 0
endif
endif
if InputLength > AnswerLength
I$ = ""
Answer = ""
InputLength = 0
endif
endfunction
function CheckHeight()
if TextHeight > 400 then Failed()
endfunction
function NewProblem()
num1 = rnd(10)
num2 = rnd(10)
num3 = num1 + num2
AnswerLength = len(str$(num3))
InputLength = 0
I$ = ""
TextHeight = 15
Answer = ""
endfunction
function Failed()
dec Lives
if Lives < 1
cls
Print "Game Over"
print ""
print "Your Score was ",Score," ... Well done!"
print ""
print "Do you want to play again?"
sync
repeat
A$ = inkey$()
until A$ = "y" or A$ = "Y" or A$ = "n" or A$ = "N"
if A$ = "Y" or A$ = "y"
NewGame()
else
end
endif
else
NewProblem()
endif
endfunction
function NewGame()
Lives = 3
Score = 0
NewProblem()
endfunction
Another idea would be to speed up the falling text evertime the user gets a question correct. Let me know if you need help with it