'TWG
Setup:
 Window 1,"Memorizer 1.0",(150,50)-(500,164),30
 FONT "topaz",8
 Randomize Timer
 Null=Rnd
 Lev=1
 Gosub Gfx
 On Window Gosub Gnd
 Window on      

SubPrograms:
 SUB text(t$)
     Locate 12,2:? Space$(40);
     Locate 12,2:? t$;
 END SUB
 SUB one
   shared lev
   line(17,19)-(167,46),2,bf
   sound 450,1
   sleep for .25/lev
   line(17,19)-(167,46),0,bf 
 END SUB
 SUB two
   shared lev
   line(173,19)-(323,46),2,bf
   sound 500,1
   sleep for .25/lev
   line(173,19)-(323,46),0,bf
 END SUB
 SUB three
   shared lev
   line(17,50)-(167,77),2,bf
   sound 550,1
   sleep for .25/lev
   line(17,50)-(167,77),0,bf 
 END SUB
 SUB four
   shared lev
   sound 600,1
   line(173,50)-(323,77),2,bf
   sleep for .25/lev
   line(173,50)-(323,77),0,bf  
 END SUB
 Dim Moves(10)
 Move=0
 UMove=0
WaitForStart:
 Text("Memorizer 1.0 - Click a gadget to start!")
 Gadget Wait(0)
 text("Get ready!")
 sleep for 2
 lev$="Level "+str$(lev)
 text(lev$) 

Main:
 Move=Move+1
 if move>1 then
 for reshow=1 to move-1
   Buttn=moves(reshow)
   If buttn=1 then call one
   if buttn=2 then call two
   if buttn=3 then call three
   if buttn=4 then call four
   sleep for .25

 next reshow
 end if

 Buttn=cint(rnd*3)+1
 If buttn=1 then call one
 if buttn=2 then call two
 if buttn=3 then call three
 if buttn=4 then call four
 Moves(move)=buttn
 Umove=0
 Repeat
   umove=umove+1
   Gadget Wait(0)
   Gosub Gad

   If Ugad<>Moves(umove) then
     text("You lose! Try again!")
     playagain=MsgBox("Oops! You lose!","Try Again","Bye!")
     if playagain=-1 then
       move=0
       umove=0
       lev=1
       goto waitforstart
     else
       goto Gnd
     end if
   end if
 Until umove=move
 sleep for .75
 If Move=10 then
   text("Hooray!")
   win=msgbox("You win! Good job! Try the next level?","Yeah","I don't think so!")
   if win=-1 then
     move=0
     umove=0
     lev=1
   else
     goto Gnd
   end if

   Goto Gnd
 End If
 Goto Main
Gad:
 Ugad=gadget(1)
 If ugad=2 then
  one
 end if

 If ugad=3 then
  two
 end if

 If ugad=4 then
  three
 end if

 If ugad=5 then
  four
 end if
ugad=ugad-1
Return

Gfx:
 BevelBox(4,2)-(336,84),1
 BevelBox(14,17)-(327,79),2
 Bevelbox(5,86)-(335,96),2 'message box
 Locate 2,18:?"Memorizer"
 Gadget 2,1,"",(15,18)-(170,48),1
 Gadget 3,1,"",(171,18)-(326,48),1
 Gadget 4,1,"",(15,49)-(170,79),1
 Gadget 5,1,"",(171,49)-(326,79),1
Return

Gnd:
  Window Close 1
  End


