Generate a boggle puzzle - including a countdown timer.
'** 12/30/2002 5:29:54 PM '** Boogle - a boggle clone '** by Thomas and Alyce Watson True = 1 : False = 0 Dim cubes$(25,6) Dim grid$(5,5) [InitCubes] For i=1 to 25 For j=1 to 6 Read a$ cubes$(i,j)=a$ Next j Next i m$="This is a boggle board simulator. " m$=m$+"Click the NEW Button to create a puzzle. " m$=m$+"A Timer will count down 300 seconds. " m$=m$+"Grab a pencil and paper and write down as " m$=m$+"many words as you can. Each word must have at " m$=m$+"three letters. You can't reuse the tiles, but " m$=m$+"you can go in any direction to make the words. " m$=m$+"If you prefer, you can print a hard-copy of " m$=m$+"the puzzle." notice m$ [WindowSetup] NoMainWin WindowWidth = 432 : WindowHeight = 359 UpperLeftX = Int((DisplayWidth-WindowWidth)/2) UpperLeftY = Int((DisplayHeight-WindowHeight)/2) [ControlSetup] Menu #1, "&File", "&New", [new], | ,_ "&Print", [print], | , "E&xit", [quit] Graphicbox #1.g, 1, 1, 302, 302 Statictext #1.label, "Time Left:", 326, 90, 100, 24 Statictext #1.count, "300", 346, 120, 100, 24 Button #1.new, "New",[new],UL, 312, 5, 105, 25 Button #1.exit, "Exit",[quit],UL, 312, 35, 105, 25 Open "Boogle" For Window_nf As #1 Print #1, "trapclose [quit]" Print #1.g, "down; fill White; flush" Print #1, "font ms_sans_serif 10" Print #1.g, "font courier_new 30 37" [loop] Wait [quit] Close #1 : End [new] GoSub [doLetters] GoSub [drawGrid] secondsLeft=300 Print #1.count, Str$(secondsLeft) Timer 1000, [activateTimer] 'initialize the timer Wait [activateTimer] secondsLeft=secondsLeft-1 Print #1.count, Str$(secondsLeft) If secondsLeft=0 Then [endGame] GoTo [loop] [endGame] Timer 0 Notice "Time is up." Wait [print] #1.g "getbmp boogle 0 0 300 300" BmpSave "boogle", "boogle.bmp" RunFile$=GetShortPathName$(DefaultDir$+"\boogle.bmp") Run "mspaint.exe " + RunFile$ + " /p", HIDE UnloadBmp "boogle" Wait [drawGrid] #1.g "cls; color black" For i = 60 to 300 step 60 #1.g "Line ";i;" 0 ";i;" 300" Next For j = 60 to 300 step 60 #1.g "Line 0 ";j;" 300 ";j Next For x=1 to 5 For y=1 to 5 lx=(x-1)*60+15 ly=(y-1)*60+45 #1.g, "place ";lx;" ";ly #1.g, "\";grid$(x,y) Next Next Return Function GetShortPathName$(lPath$) sPath$=Space$(256) 'create string buffer lenPath=Len(sPath$) 'length of buffer CallDLL #kernel32, "GetShortPathNameA",_ lPath$ As ptr,_ 'long pathname sPath$ As ptr,_ 'buffer to receive short path name lenPath As long,_ 'length of buffer r As long 'length of returned string GetShortPathName$=Left$(sPath$,r) End Function [doLetters] GoSub [clearGrid] For i=1 to 25 n=Int(Rnd(0)*6+1) x=Int(Rnd(0)*5+1) y=Int(Rnd(0)*5+1) While grid$(x,y)<>"" x=Int(Rnd(0)*5+1) y=Int(Rnd(0)*5+1) Wend grid$(x,y)=cubes$(i,n) Next Return [clearGrid] For x=1 to 5 For y=1 to 5 grid$(x,y)="" Next Next Return [dataStuff] Data i,t,c,s,e,p Data a,r,a,s,a,f Data e,e,e,e,a,a Data o,d,h,n,t,h Data r,w,v,o,g,r Data o,u,o,t,w,n Data r,a,s,a,i,f Data qu,x,z,k,j,b Data r,i,s,p,y,f Data n,d,l,o,h,r Data p,l,e,t,c,i Data t,w,s,c,n,c Data o,l,d,h,r,h Data n,n,e,n,d,a Data e,e,e,e,a,m Data e,t,m,t,t,o Data m,n,n,e,g,a Data l,d,n,r,d,o Data m,g,a,e,u,e Data p,r,i,y,h,r Data e,t,i,l,c,i Data n,s,s,s,u,e Data r,f,s,y,a,i Data o,t,t,u,o,o Data e,t,i,t,i,i