Code:
!this is a program that allows the user a chance to click in a box that has an image
!appear in it. It then tells the user how long it took for them to click the boxes.
!a random city scene to demonstrate my graphic ability
PRINT "Welcome to my program. You will be asked to pay attention"
PRINT "to where some figures appear in a grid for later use."
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press any key to continue..."
PRINT " and ENJOY THE VIEW!"
GET KEY dummy
SET MODE "graphics"
SET WINDOW 0, 3, 0, 3
BOX LINES 1, 2, 1, 2 !makes a box on the screen
!the following lines give the dimensions and colors for the city buildings
BOX LINES 1, 1.15, 1, 1.5
SET COLOR "253"
FLOOD 1.1, 1.2
BOX LINES 1.15, 1.29, 1, 1.8
SET COLOR "251"
FLOOD 1.16, 1.7
BOX LINES 1.29, 1.41, 1, 1.65
SET COLOR "254"
FLOOD 1.31, 1.63
BOX LINES 1.41, 1.53, 1, 1.49
SET COLOR "253"
FLOOD 1.42, 1.48
BOX LINES 1.53, 1.67, 1, 1.75
SET COLOR "251"
FLOOD 1.54, 1.6
BOX LINES 1.67, 1.85, 1, 1.4
SET COLOR "252"
FLOOD 1.7, 1.3
BOX LINES 1.85, 2, 1, 1.84
SET COLOR "253"
FLOOD 1.9, 1.8
!the moon in the sky
BOX CIRCLE 1.75, 1.85, 1.85, 1.98
SET COLOR "2"
FLOOD 1.76, 1.95
!the color of the sky is a deep blue
SET COLOR "239"
FLOOD 1.1, 1.9
PAUSE 2.5
CLEAR
!****************************************************************************************************************
SET MODE "graphics"
RANDOMIZE
LET n = 4
LET wm = 1
LET ratio = 640/480
SET WINDOW 0-(wm*ratio), n+(wm*ratio), 0-wm, n+wm
CALL icon(n,rainbow$,im)
CALL grid(n)
CALL showbox(n,rainbow$,im,p)
CALL clicker(p,n)
PAUSE 1
PRINT "Thanks for using my program. Click anywhere to return to the beginning."
END
!beginning of subroutines
!****************************************************************************************************************
SUB icon(n,rainbow$,im)
LET im = 0.06
!the rainbow colored lines that will appear in each box
SET COLOR "red"
BOX LINES 0+im, 1-im, n-1+im, n-im
SET COLOR "yellow"
BOX LINES .1+im, .9-im, n-.9+im, n-im
SET COLOR "green"
BOX LINES .2+im, .8-im, n-.8+im, n-im
SET COLOR "blue"
BOX LINES .3+im, .7-im, n-.7+im, n-im
SET COLOR "90"
BOX LINES .4+im, .6-im, n-.6+im, n-im
BOX KEEP 0+im, 1-im, n-1+im, n-im IN rainbow$
SET COLOR "black"
PRINT "Pay attention to where the box, shown below, full of colorful lines appears."
PRINT "Press any key to continue..."
GET KEY dummy
PLAY "d"
PAUSE 1
CLEAR
END SUB
!****************************************************************************************************************
SUB grid(n)
SET COLOR "black"
FOR r = 1 to n
FOR c = 1 to n
BOX LINES c-1, c, r-1, r
PAUSE 0.5
NEXT c
NEXT r
PAUSE 1
END SUB
!****************************************************************************************************************
SUB showbox(n,rainbow$,im,p)
LET p = 3
FOR i = 1 to p
LET r = int(n*rnd) + 1
LET c = int(n*rnd) + 1
BOX SHOW rainbow$ at c-1+im, r-1+im
PLAY "d"
PAUSE 0.5
BOX CLEAR c-1+im, c-im, r-1+im, r-im
PAUSE 0.5
NEXT i
END SUB
!****************************************************************************************************************
SUB clicker(p,n)
PLAY "c d"
PRINT "Click the mouse on the squares where you saw the colorful boxes..."
LET startTime = TIME
LET clicks = 0
DO
DO
GET MOUSE x, y, s
LOOP until s = 3
PLAY "g"
CALL finder(x,y,n,c,r)
IF c = 0 and r = o then
PRINT "clicked out of grid"
ELSE
PRINT "column="; c ; " row=" ; r
END IF
LET clicks = clicks + 1
LOOP until clicks = p
LET endTime = TIME
LET elapsedTime = endTime - startTime
LET elapsedTime = round(elapsedTime, 1)
PRINT "It took you" ; elapsedTime ; "seconds!"
END SUB
!***********************************************************************************************************
SUB finder(x,y,n,c,r)
IF x < 0 or y < 0 or x>= n or y >=n then
LET c = 0
LET r = 0
ELSE
LET c = int(x) + 1
LET r = int(y) + 1
END IF
END SUB