Hi,
I've been working on my first "major" program, which is a program that simply dishes out math facts. That worked well enough, but now I want a timer. I know, to some degree, how to create a timer on its own, but the only command that I know that can recieve text input from the computer is INPUT, and that command apparently stops the loop until the data has been entered. So every time a new fact problem appears, the clock is stalled until the data has been entered, which is not what I want at all.
So how do I create a timer that will keep on ticking, even if the program is waiting for the user to enter data?
Thanks,
Dan
Here's the entire game code, if it's needed. (this is the code in it's messed up form, with a timer that doesn't work.)
rem first, we go through some pregame commands, and define some variable for later use
RANDOMIZE TIMER()
right = 0
wrong = 0
seconds = 60
time = 0
hide mouse
rem opening message
center text 320,200,"Welcome to Multiplication Fact Practicer. Press any key to continue."
suspend for key
cls
rem here we ask the user some pre-game questions to better suit their practicing
MainGame:
print "How many facts would you like to be given?";
input fact
print "What would you like the range of facts to be? (e.g. '12' would"
input "be selecting all of the facts between 1x1 and 12x12) "; range
cls
wait 200
center text 320, 100,"All options are set. Press any key to start practicing!"
suspend for key
cls
wait 500
set text font "Comic Sans ms"
set text size 18
do
time = time + 1
set cursor 10,10
print "Time left: ";seconds
if time = 1000
time = 0
seconds = seconds - 1
endif
if seconds = 0
cls
wait 500
center text 320,200, "Your time has run out!"
wait 1000
cls
GOSUB TimeOut
endif
fact1 = rnd(range)
fact2 = rnd(range)
set cursor 160,200
print "Right: ";right
set cursor 480,200
print "Wrong: ";wrong
set cursor 320,10
print fact1;"x";fact2;"=";
input answer
rem now we figure out what to do, depending on whether the user got the problem right
if answer = (fact1*fact2)
right=right+1
center text 320,30,"right!"
wait 500
cls
factnumbers = fact + 1
endif
if answer <> (fact1*fact2)
wrong=wrong+1
center text 320,30,"wrong!"
wait 500
cls
factnumbers = factnumbers + 1
endif
loop
rem now that the practicing is over, we display the final results
wait 500
TimeOut:
set cursor 280,150
print "Answers Right: ";right
set cursor 280,170
print "Answers Wrong: ";wrong
wait 1000
set cursor 280,240
rem here we ask if they want to start over
input "Do you want to start over? (yes/no)";startover$
if startover$ = "yes"
right = 0
wrong = 0
cls
GOTO MainGame
endif
if startover$ = "y"
right = 0
wrong = 0
cls
GOTO MainGame
endif
if startover$ = "no"
cls
wait 300
center text 320,150,"Thanks for playing!"
wait 1000
cls
end
endif
if startover$ = "n"
cls
wait 300
center text 320,150,"Thanks for playing!"
wait 1000
cls
end
endif
EDIT: sorry, I forgot to mention that I am doing this in DBpro.