_TITLE "Math Magic"


COLOR 4

SCREEN _NEWIMAGE(1800, 1024, 32)

image1 = _LOADIMAGE("mathfun.png")

_PUTIMAGE (0, 0), image1



fontsize = 15
italic = 0
bold = 1

fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\verdana.ttf"
style$ = "MONOSPACE"
IF italic = 1 THEN style$ = style$ + ", ITALIC"
IF bold = 1 THEN style$ = style$ + ", BOLD"
currentf& = _LOADFONT(fontpath$, fontsize, style$)
_FONT currentf&



COLOR _RGB(0, 255, 255): PRINT "Are you a master of MATH?  Let's find out!"




DIM operator AS INTEGER

COLOR _RGB(0, 255, 255): PRINT "Choose your operator! press 1 multiplication 2 addition 3 division 4 subtraction"

INPUT operator




COLOR _RGB(0, 255, 255): PRINT "Choose your difficulty! Press 1 for level one 2 for level two 3 for level three 4 for level four 5 for level five"
COLOR _RGB(0, 255, 255): PRINT "6 for level six 7 for level seven and 8 for level eight"

INPUT difficulty

IF difficulty = 1 THEN
    maxnum1 = 5
    maxnum2 = 5
END IF

IF difficulty = 2 THEN
    maxnum1 = 12
    maxnum2 = 12
END IF

IF difficulty = 3 THEN
    maxnum1 = 99
    maxnum2 = 9
END IF

IF difficulty = 4 THEN
    maxnum1 = 999
    maxnum2 = 9
END IF

IF difficulty = 5 THEN
    maxnum1 = 99
    maxnum2 = 99
END IF

IF difficulty = 6 THEN
    maxnum1 = 999
    maxnum2 = 99
END IF

IF difficulty = 7 THEN
    maxnum1 = 999
    maxnum2 = 999
END IF

IF difficulty = 8 THEN
    maxnum1 = 9999
    maxnum2 = 9999
END IF







RANDOMIZE TIMER


DIM m1 AS INTEGER
DIM m2 AS INTEGER


DIM score AS INTEGER
DIM test_length AS INTEGER
DIM test AS INTEGER

score = 0

test_length = 10

test = 0
DO


    m1 = INT(RND * (maxnum1 + 1))
    m2 = INT(RND * (maxnum2 + 1))


    tries = 0
    DO
        IF operator = 1 THEN
            COLOR _RGB(255, 255, 0): PRINT m1; "x"; m2; "= ";
            answer = m1 * m2
        END IF

        IF operator = 2 THEN
            COLOR _RGB(255, 255, 0): PRINT m1; "+"; m2; "= ";
            answer = m1 + m2
        END IF

        IF operator = 3 THEN
            COLOR _RGB(255, 255, 0): PRINT m1; "/"; m2; "= ";
            answer = m1 / m2
        END IF

        IF operator = 4 THEN
            COLOR _RGB(255, 255, 0): PRINT m1; "-"; m2; "= ";
            answer = m1 - m2
        END IF



        INPUT guess

        IF guess < answer THEN
            COLOR _RGB(255, 0, 0): PRINT "too low"
        END IF

        IF guess > answer THEN
            COLOR _RGB(255, 0, 0): PRINT "too high"
        END IF


        tries = tries + 1

    LOOP UNTIL guess = answer

    COLOR _RGB(0, 255, 0): PRINT "you got it in "; tries; "tries."

    IF tries = 1 THEN score = score + 1


    test = test + 1

LOOP UNTIL test = test_length

COLOR _RGB(0, 255, 0): PRINT "you got "; score; " of "; test_length; " correct on the first try!"