_TITLE "Flash Card Math Trainer"
WF
= _LOADFONT("C:\Windows\Fonts\Cour.ttf", 150)
RST
= _LOADFONT("C:\Windows\Fonts\Cour.ttf", 50)
CONST Plus
= 1, Minus
= 2, Times
= 3, Divide
= 4
MainChoiceScreen mode, Difficulty, length
SELECT CASE length
'This is the number of seconds we're going to test ourselves
SELECT CASE Difficulty
'This determines how hard the game will be CASE 1: LowLimit
= 0: HighLimit
= 10 CASE 2: LowLimit
= 0: HighLimit
= 12 CASE 3: LowLimit
= 0: HighLimit
= 99 CASE 4: LowLimit
= 10: HighLimit
= 89
num1
= RND * HighLimit
+ LowLimit
SELECT CASE mode
'Only give the user the numbers they wanted to play with
num2
= RND * HighLimit
+ LowLimit
IF op
= 4 THEN 'it's divide, let's get the numbers in the proper order num1
= RND * HighLimit
+ LowLimit
num2
= RND * HighLimit
+ LowLimit
num1 = num1 * num2
DrawCard num1, op, num2
DrawUserClickAreas
GetUserAnswer answer$
CheckAnswer num1, op, num2, answer$
DisplayTime
SUB MainChoiceScreen
(mode
, difficulty
, length
) PRINT "Welcome to Math Flash!" PRINT "What would you like to learn to work with today?" PRINT "3) Addition and Subtraction" PRINT "4) Multiplication" PRINT "6) Multiplication and Division" PRINT "7) Addition and Multiplication" PRINT "9) QUIT THE TRAINER"
PRINT "How difficult do you wish for this game to be?"
PRINT "How long a game do you want?" PRINT "5) Bring It On, Long!"
PRINT "<LEFT CLICK> TO BEGIN MATH FLASH CARDS!" x = mouseclick
mode = a: difficulty = b: length = c
GameTime = GameTime - 1
IF GameTime
<= 0 THEN ShowResults
'Clock has ran out
Score = 0
PRINT "YOUR ANSWER";
TAB(40);
"CORRECT ANSWER" text$ = Num2Str(Results(i).num1)
CASE 1: text$
= text$
+ " + " CASE 2: text$
= text$
+ " - " CASE 3: text$
= text$
+ " * " CASE 4: text$
= text$
+ " / "
IF Results
(i
).correct
= -1 THEN Correct = Correct + 1
YourText$ = text$ + Num2Str(Results(i).num2) + " = " + Num2Str(Results(i).answer)
Wrong = Wrong + 1
IF Results
(i
).correct
= 1 THEN YourText$ = text$ + Num2Str(Results(i).num2) + " = " + "SKIPPED"
YourText$ = text$ + Num2Str(Results(i).num2) + " = " + Num2Str(Results(i).answer)
CorrectText$ = text$ + Num2Str(Results(i).num2) + " = " + Num2Str(Results(i).num3)
PRINT "You got "; Correct;
" correct answers, and "; Wrong;
" wrong." PRINT "If this was a test, you would have scored ";
INT(100 * (Correct
/ (i
- 1)));
"%" ScoreMultiplier = 25 * Difficulty
Score = ScoreMultiplier * Correct + ScoreMultiplier * -Wrong
PRINT "YOUR GAME SCORE IS: "; Score
CASE 1: file$
= "Easy.txt": diff$
= "EASY" CASE 2: file$
= "Average.txt": diff$
= "NORMAL" CASE 3: file$
= "Hard.txt": diff$
= "HARD" CASE 4: file$
= "Grueling.txt": diff$
= "GRUELING" 'life should be good as we have an existing file.
'if not, then let's make a blank highscore file for the proper difficulty.
HS = 0 'no high score until we validate it
PRINT "CONGRATULATIONS!! YOU GOT A HIGH SCORE!" PRINT "What name would you like to be known by? ";
IF i
< 25 THEN person
(i
+ 1) = person
(i
): score
(i
+ 1) = score
(i
): diff$
(i
+ 1) = diff$
(i
) person(i) = person$: score(i) = Score: diff$(i) = diff$
i = i + 1: HS = -1
PRINT "Press <ANY KEY> to see the "; diff$;
" HIGH SCORES" PRINT diff$;
" HIGH SCORERS"
PRINT "Do the test again? (Y/N)"
SUB CheckAnswer
(num1
, op
, num2
, answer$
) CASE Plus: num3
= num1
+ num2
CASE Minus: num3
= num1
- num2
CASE Times: num3
= num1
* num2
CASE Divide: num3
= num1
/ num2
QuestionsAsked
= UBOUND(results
) + 1Results(QuestionsAsked).num1 = num1
Results(QuestionsAsked).op = op
Results(QuestionsAsked).num2 = num2
Results(QuestionsAsked).num3 = num3
Results(QuestionsAsked).answer = ans
Correct = Correct + 1
GameTime = GameTime + 1 'A bonus to time for each correct answer
Results(QuestionsAsked).correct = -1
Wrong = Wrong + 1
GameTime = GameTime - 2 'A penalty to time for each wrong answer
Results(QuestionsAsked).correct = 0
IF answer$
= "" THEN Results
(QuestionsAsked
).correct
= 1 DisplayTime
SUB DisplayUserAnswer
(answer$
) LINE (700, 100)-(1100, 300), White
, BF
top = 125
left = (400 - GetPrintWidth(answer$, WF)) / 2 + 700
SUB GetUserAnswer
(answer$
) done = 0: answer$ = ""
Button = mouseclick
IF Button
= 1 THEN 'We have a mouse click somewhere IF y
>= 400 AND y
<= 600 THEN 'they clicked down where the numbers and OK button are num = 0
IF x \
100 = (x
+ 10) \
100 THEN num
= x \
100 'they didn't click on the 10 pixel blank space between numbers IF num
> 0 AND num
< 12 THEN 'It's a click on either a number or the OK button on the top row done = -1
IF y
>= 610 AND y
<= 710 AND x
>= 100 AND x
<= 1200 THEN done
= -1 'Click on the bottom ENTER area DisplayUserAnswer answer$
DisplayTime
left = 100 * i
LINE (left
, 400)-(left
+ 90, 600), Yellow
, BF
LINE (100, 610)-(1200, 710), Green
, BF
LINE (1100, 400)-(1200, 710), Green
, BF
SUB DrawCard
(num1
, operator
, num2
) 'Pass it our 3 numbers like 3, plus, 3 would be 3 + 3 = ? LINE (100, 100)-(650, 300), White
, BF
text$ = Num2Str(num1)
CASE Plus: text$
= text$
+ "+" CASE Minus: text$
= text$
+ "-" CASE Times: text$
= text$
+ "*" CASE Divide: text$
= text$
+ "/" text$ = text$ + Num2Str(num2) + "="
top = 125
left = (550 - GetPrintWidth(text$, WF)) / 2 + 100
p = 0 'pointer
_MEMGET m
, m.OFFSET
+ p
, c
'Get our color p = p + 4 'increase 4 as we're working with 4-byte long values for RGBA color
GetPrintWidth = GetPrintWidth + 1
scroll%
= scroll%
+ _MOUSEWHEEL ' if scrollwheel changes, watch the change here speedup = 1
speedup = 2
speedup = 3
IF speedup
THEN 'buton was pushed down mouseclickxxx1%
= _MOUSEX: mouseclickyyy1%
= _MOUSEY 'see where button was pushed down at LOOP 'finishes when button is let up IF mouseclickxxx1%
>= _MOUSEX - 2 AND mouseclickxxx1%
<= _MOUSEX + 2 AND mouseclickyyy1%
>= _MOUSEY - 2 AND mouseclickyyy1%
<= _MOUSEY + 2 THEN 'if mouse hasn't moved (ie clicked down, dragged somewhere, then released) mouseclick% = speedup
mouseclick% = 0
IF scroll%
< 0 THEN mouseclick%
= 4 IF scroll%
> 0 THEN mouseclick%
= 5