!Mouse game
!Commands used - 23 total
!external function, set mode, set window, option nolet, randomize, do-loop, print, input prompt, select case, Int(), external subroutine,
!set color, for-loop, box area, pause, box clear, get mouse, plot, if-else-end if, elseif, exit do, sound, plot text
declare function lose
Set Mode "GRAPHICS"
Set Window 0, 1.4, 0, 1
Option nolet
Randomize
check = 0
s = 0.05
do
check$ = "true"
print "Start at green, click and hold the mouse and get to red as fast as possible"
print "Don't hit the walls...."
input prompt "Enter difficulty level, 1 (easy) to 3 (hard): ": level
select case Int(level)
case is =1
gap = 0.1
case is =2
gap = 0.075
case is =3
gap = 0.05
case else
print "invalid choice"
check$ = "false"
end select
loop while check$ = "false"
do
y1 = 0.2 + 0.2*rnd
y2 = 0.4 + 0.4*rnd
loop until 0.5-y1+y2<0.9
x1 = 0.5 + rnd
x2 = 0.5 + rnd
x3 = 0.5 + rnd
x4 = 0.5 + rnd
tot = x1 + x2 + x3 + x4
x1 = (0.9-3*gap) * x1 / tot
x2 = (0.9-3*gap) * x2 / tot
x3 = (0.9-3*gap) * x3 / tot
call maze (x1, x2, x3, gap, y1, y2)
for i=0.25 to s step -s
set color "green"
box area 0.1,0.1+2*i,0.5-i,0.5+i
pause 0.1
box clear 0.1,0.1+2*i,0.5-i,0.5+i
call maze (x1, x2, x3, gap, y1, y2)
next i
set color "green"
box area 0.1,0.2,0.45,0.55
for i=0.25 to s step -s
set color "red"
box area 1.3-2*i,1.3,0.5-i,0.5+i
pause 0.1
box clear 1.3-2*i,1.3,0.5-i,0.5+i
call maze (x1, x2, x3, gap, y1, y2)
next i
set color "red"
box area 1.2,1.3,0.45,0.55
Do
Get Mouse X,Y,S
Loop Until x>0.1 and x<0.2 and y>0.45 and y<0.55 and S=1
t1 = time
Do While S = 1
set color "Red"
Get Mouse X,Y,S ! a sequence of x,y points
Plot X,Y; ! are generated
if x<1.3 and x>1.2 and y<0.55 and y>0.45 then
Plot Text, at .1, .9: "You Win!"
t2 = time
check = 1
exit do
elseif (x>0.05 and x<0.25) and (y<0.4 or y>0.6) then
check = lose(0)
exit do
elseif (x>0.25 and x<0.25+x1) and (y<0.5-0.5*gap or y>0.5+0.5*gap) then
check = lose(0)
exit do
elseif (x>0.25+x1 and x<0.25+x1+gap) and (y<0.5-y1 or y>0.5+0.5*gap) then
check = lose(0)
exit do
elseif (x>0.25+x1+gap and x<0.25+x1+gap+x2) and (y<0.5-y1 or y>0.5-y1+gap) then
check = lose(0)
exit do
elseif (x>0.25+x1+gap+x2 and x<0.25+x1+2*gap+x2) and (y<0.5-y1 or y>0.5-y1+y2) then
check = lose(0)
exit do
elseif (x>0.25+x1+2*gap+x2 and x<0.25+x1+2*gap+x2+x3) and (y<0.5-y1+y2-gap or y>0.5-y1+y2) then
check = lose(0)
exit do
elseif (x>0.25+x1+2*gap+x2+x3 and x<0.25+x1+3*gap+x2+x3) and (y<0.5-0.5*gap or y>0.5-y1+y2) then
check = lose(0)
exit do
elseif (x>0.25+x1+3*gap+x2+x3 and x<1.15) and (y<0.5-0.5*gap or y>0.5+0.5*gap) then
check = lose(0)
exit do
elseif (x>1.15 and x<1.35) and (y<0.4 or y>0.6) then
check = lose(0)
exit do
elseif (x<0.05 or x>1.35) then
check = lose(0)
exit do
else
end if
Loop
if check = 1 then
Input prompt "Enter your name: ": name$
print "Good job "; name$; ", your time was: "; (t2-t1); " seconds"
elseif check = 0 then
Print "Try again Loser"
else
Print "Thanks for playing"
end if
pause 1
end
function lose(x)
sound 1000, 0.1
Plot Text, at .1, .9: "You Lose!"
lose = x
end function
sub maze (x1, x2, x3, gap, y1, y2)
set color "black"
box area 0, 0.05, 0, 1
box area 0.05, 0.25, 0.6, 1
box area 0.05, 0.25, 0, 0.4
box area 0.25, 0.25+x1, 0.5+0.5*gap, 1
box area 0.25, 0.25+x1, 0, 0.5-0.5*gap
box area 0.25+x1,0.25+x1+gap, 0.5+0.5*gap, 1
box area 0.25+x1,0.25+x1+gap, 0, 0.5-y1
box area 0.25+x1+gap, 0.25+x1+gap+x2, 0.5-y1+gap, 1
box area 0.25+x1+gap, 0.25+x1+gap+x2, 0, 0.5-y1
box area 0.25+x1+gap+x2, 0.25+x1+2*gap+x2, 0.5-y1+y2, 1
box area 0.25+x1+gap+x2, 0.25+x1+2*gap+x2, 0, 0.5-y1
box area 0.25+x1+2*gap+x2, 0.25+x1+2*gap+x2+x3, 0.5-y1+y2, 1
box area 0.25+x1+2*gap+x2, 0.25+x1+2*gap+x2+x3, 0, 0.5-y1+y2-gap
box area 0.25+x1+2*gap+x2+x3, 0.25+x1+3*gap+x2+x3, 0.5-y1+y2, 1
box area 0.25+x1+2*gap+x2+x3, 0.25+x1+3*gap+x2+x3, 0, 0.5-0.5*gap
box area 0.25+x1+3*gap+x2+x3, 1.15, 0.5+0.5*gap, 1
box area 0.25+x1+3*gap+x2+x3, 1.15, 0, 0.5-0.5*gap
box area 1.15, 1.35, 0.6, 1
box area 1.15, 1.35, 0, 0.4
box area 1.35, 1.4, 0, 1
end sub