I liked your program and I decided it would put my new "rand" functions to good use. So I edited your code and made a new version of it. The "rand" functions link is here:
http://forum.thegamecreators.com/?m=forum_view&t=78628&b=6
I changed quite a bit, but the original idea is still there...I tried to stick to the original code as much as possible. Here's the code:
hide mouse
disable escapeKey
center text 320, 240, "SPEED PROGRAMING" : fadeScreen(100, 50, 5, 100)
center text 320, 240, "BY: CLASSIC EVIL" : fadeScreen(100, 50, 5, 100)
cls
_setDifficulty:
ink rgb(255, 255, 255), 0
print "Select your level of difficulty"
print "-------------------------------"
print
print "1 - practice (timer = 5000)"
print "2 - easy (timer = 4000)"
print "3 - medium (timer = 3000)"
print "4 - hard (timer = 2000)"
print "5 - very hard (timer = 1500)"
print "6 - expert (timer = 1000)"
print "7 - custom (timer = x)"
print "8 - QUIT"
print
input "Select: ", choice
select choice
case 1 : ctime = 5000 : endCase
case 2 : ctime = 4000 : endCase
case 3 : ctime = 3000 : endCase
case 4 : ctime = 2000 : endCase
case 5 : ctime = 1500 : endCase
case 6 : ctime = 1000 : endCase
case 7 : input "Enter amount of time: ", ctime : endCase
case 8 : end : endCase
case default
cls
print "Select a choice from 1 to 8!!!"
print
goto _setDifficulty
endCase
endSelect
`end of _setDifficulty
print "press any key to start..."
suspend for key
randomize timer()
totalValues = totalLinesInFile("keycodes.txt")
new = 0
score = 0
do
goSub _outputData
if new = 0 then goSub _newLetter
if len(inKey$()) > 0 then goSub _checkInput
if timer() = endTime then goSub _timesUp
if escapeKey() = 1 then cls : goto _setDifficulty
loop
_newLetter:
keyCode$ = chr$(Val(randStringFromFile("keycodes.txt", totalValues)))
endTime = (timer() + cTime)
new = 1
return
_checkInput:
if inkey$() = keyCode$
inc score
new = 0
endIf
return
_outputData:
cls
ink rgb(255, 255, 255), 0 : text 300, 150, keyCode$
ink rgb(0, 255, 0), 0 : text 280, 170, ("score = " + str$(score))
ink rgb(255, 0, 0), 0 : text 280, 190, ("timer = " + str$(endTime - timer()))
return
_timesUp:
ink rgb(0, 0, 255), 0
text 280, 210, "Times Up"
wait 3000
cls
goto _setDifficulty
return
function fadeScreen(startAt, endAt, rate, delay)
for fade = startAt To endAt step (0 - rate)
fade bitmap 0, int(fade) : sync
wait delay
next fade
endFunction
function randInt(min, max)
rand = (rnd(max - min) + min)
endFunction rand
function randStringFromFile(file$, totalValues)
randLine = (rnd(totalValues - 1) + 1)
open to read 32, file$
for lineNum = 1 to randLine
read string 32, string$
next lineNum
close file 32
endFunction string$
function totalLinesInFile(file$)
open to read 32, file$
while file end(32) = 0
inc lineTotal
read string 32, string$
endWhile
close file 32
endFunction lineTotal
Here's the "keycodes.txt" file:
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
49
50
51
52
53
54
55
56
57
48
45
61
91
93
59
39
44
46
47
92
(I've also attached the .exe file to this post)
Their is still room for improvement though...you may want to add an option for enabling/disabling the number keys(1, 2, 3, etc.). If I were you, I would just keep making it better and better. If you have any questions/comments, please let me know
EDIT: I did this in DBPro...it should work for DBC though too.