No. You're using functions to repeat things... don't go backwards in your learning.
I would get rid of TextColumnNum and change some lines in the NewProblem() function. There's no need to have it pick a random number for specific columns when the entire screen can easily be used.
Like this:
sync on
sync rate 30
hide mouse
randomize timer()
Global num1
Global num2
Global num3
Global TextHeight
Global TextColumn
Global Score
Global Lives
Global Answer as string
Global LastInput as string
Global InputLength
Global AnswerLength
rem load image "C:Documents and SettingsDC JonesMy DocumentsMy PicturesCory's gameNumber GameOne Digit.bmp",1,1
rem load image "C:Documents and SettingsDC JonesMy DocumentsMy PicturesCory's gameNumber GameTwo Digits.bmp",2,1
NewGame()
do
cls
DisplayProblem()
GetUserInput()
CheckAnswer()
CheckHeight()
sync
Loop
function DisplayProblem()
set cursor 0,0
Print "Lives: ",Lives," Score: ",Score
set cursor TextColumn,TextHeight+80
print str$(num1)+"+"+ str$(num2)
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,50
NewProblem()
else
I$ = ""
Answer = ""
InputLength = 0
endif
endif
if InputLength > AnswerLength
I$ = ""
Answer = ""
InputLength = 0
endif
endfunction
function CheckHeight()
if TextHeight > 350 then Failed()
endfunction
function NewProblem()
num1 = rnd(10)
num2 = rnd(10)
num3 = num1 + num2
AnswerLength = len(str$(num3))
InputLength = 0
I$ = ""
TextHeight = 15
Answer = ""
a$=str$(num1)+"+"+str$(num2)
TextColumn=rnd(640-text width(a$))
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? Y/N"
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()
flush video memory
Lives = 3
Score = 0
NewProblem()
endfunction
In NewProblem() I added:
a$=str$(num1)+"+"+str$(num2)
TextColumn=rnd(640-text width(a$))
a$ is just a temporary string to find out what the text length of it will be on the screen so it can be subtracted from the random x coordinate picked. If you want this program to allow other kinds of problems instead of just adding... you might want to look at making a$ something else and making it global. You can then look up in the help files how to use "select" and "case" to pick different problems in that function. If that is what you want and you have problems i'll show you how to use "select" and "case".
Also there are small changes that you can put in that would make it easier. Like instead of using "set cursor" and "print" you can use "text" and do the same thing as both those commands combined... especially if you use my suggesting of making a$ (or whatever you pick) as global. Like: text TextColumn,TextHeight+80,a$
Hope this helps.