GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/JimMartinson/_Archive/CST1794/ExampleFiles/2008.05.08/ |
Upload File : |
[beginProgram] ' Begin code for #main 'nomainwin WindowWidth = 640 WindowHeight = 480 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) ' Begin GUI objects code ' create hangman.graphicbox and load bitmap for the hangman box background. graphicbox #main.hangman.graphicbox, 5, 17, 300, 380 loadbmp "background", "assets\background.BMP" ' Create wordToFind.statictext. statictext #main.wordToFind.statictext, "", 70, 412, 160, 20 'statictext #main.statictext9, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 330, 417, 277, 20 ' Create difficultyLevel.combobox and difficultyLevel.statictext. dim difficultyLevel$(30) difficultyLevel$(1) = "4" 'replace with loop that looks for files difficultyLevel$(2) = "5" difficultyLevel$(3) = "6" difficultyLevel$(4) = "7" difficultyLevel$(5) = "8" difficultyLevel$(6) = "9" difficultyLevel$(7) = "10" ComboboxColor$ = "white" statictext #main.difficultyLevel.statictext, "Select a difficulty level", 360, 52, 160, 20 combobox #main.difficultyLevel.combobox, difficultyLevel$(), [difficultyLevel.combobox.select], 520, 47, 45, 100 ' Create startGame.btn. button #main.startGame.btn,"Start game",[startGame.btn.click], UL, 375, 97, 87, 25 ' Create exit.btn. button #main.exit.btn,"Exit",[exit.btn.click], UL, 495, 97, 36, 25 ' Setup letter buttons button #main.A.btn,"A",letter.btn.click, UL, 350, 207, 20, 25 button #main.B.btn,"B",letter.btn.click, UL, 370, 207, 20, 25 button #main.C.btn,"C",letter.btn.click, UL, 390, 207, 20, 25 button #main.D.btn,"D",letter.btn.click, UL, 410, 207, 20, 25 button #main.E.btn,"E",letter.btn.click, UL, 430, 207, 20, 25 button #main.F.btn,"F",letter.btn.click, UL, 450, 207, 20, 25 button #main.G.btn,"G",letter.btn.click, UL, 470, 207, 20, 25 button #main.H.btn,"H",letter.btn.click, UL, 490, 207, 20, 25 button #main.I.btn,"I",letter.btn.click, UL, 510, 207, 20, 25 button #main.J.btn,"J",letter.btn.click, UL, 530, 207, 20, 25 button #main.K.btn,"K",letter.btn.click, UL, 550, 207, 20, 25 button #main.L.btn,"L",letter.btn.click, UL, 570, 207, 20, 25 button #main.M.btn,"M",letter.btn.click, UL, 590, 207, 20, 25 button #main.N.btn,"N",letter.btn.click, UL, 350, 232, 20, 25 button #main.O.btn,"O",letter.btn.click, UL, 370, 232, 20, 25 button #main.P.btn,"P",letter.btn.click, UL, 390, 232, 20, 25 button #main.Q.btn,"Q",letter.btn.click, UL, 410, 232, 20, 25 button #main.R.btn,"R",letter.btn.click, UL, 430, 232, 20, 25 button #main.S.btn,"S",letter.btn.click, UL, 450, 232, 20, 25 button #main.T.btn,"T",letter.btn.click, UL, 470, 232, 20, 25 button #main.U.btn,"U",letter.btn.click, UL, 490, 232, 20, 25 button #main.V.btn,"V",letter.btn.click, UL, 510, 232, 20, 25 button #main.W.btn,"W",letter.btn.click, UL, 530, 232, 20, 25 button #main.X.btn,"X",letter.btn.click, UL, 550, 232, 20, 25 button #main.Y.btn,"Y",letter.btn.click, UL, 570, 232, 20, 25 button #main.Z.btn,"Z",letter.btn.click, UL, 590, 232, 20, 25 ' Create guessesLeftLabel.statictext and guessesLeftNumber.statictext. statictext #main.guessesLeftLabel.statictext, "Guesses left:", 360, 282, 103, 20 statictext #main.guessesLeftNumber.statictext, "", 460, 282, 9, 20 ' End GUI objects code ' Open and setup #main open "Hangman" for window as #main ' Play some music playwave "assets\music.wav", loop [resetGame] ' Clear hangman.graphicbox print #main.hangman.graphicbox, "down; fill white; flush ;up" ' Insert background image print #main.hangman.graphicbox, "drawbmp background -40 -70" ' Disable the startGame.btn. print #main.startGame.btn, "!disable" ' Position pen in hangman.graphicbox. print #main.hangman.graphicbox, "color lightgray; size 1; home; up; north; go 100; turn 270; go 50; up; flush" print #main.hangman.graphicbox, "posxy xVar yVar" ' Build gallow Top print #main.hangman.graphicbox, "goto "+str$(xVar)+" "+str$(yVar-25)+"; color brown; size 6; down; north; go 40; up; flush" print #main.hangman.graphicbox, "color darkred; size 14; down; turn 90; go 170; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; up; turn 180; go 80; up; flush" print #main.hangman.graphicbox, "color darkred; size 12; down; turn 225;go 113.137085; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; up; turn 225; go 80; up; flush" print #main.hangman.graphicbox, "color darkred; size 14; down; turn 180; go 280; up; flush" ' Build gallow Base print #main.hangman.graphicbox, "color darkred; size 14; down; turn 90; go 200; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; up; turn 180; go 30; up; flush" print #main.hangman.graphicbox, "color darkred; size 14; down; turn 90; go 50; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; up; turn 180; go 50; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; up; turn 90; go 140; up; flush" print #main.hangman.graphicbox, "color darkred; size 14; down; turn 90; go 50; up; flush" ' Set #main fonts. print #main, "font arial 12" print #main.guessesLeftNumber.statictext, "!font arial 14 bold" ' Trap close print #main, "trapclose [quit.main]" ' Hide letter.btns gosub [letter.btn.hide] loopCount = 0 wordAsFound$ = "_" ' Stops fake win at beginning of game. guessesLeft = -1 ' Stops fake loss at beginning of game. [waitLoop] scan loopCount = loopCount + 1 print loopCount if instr(wordAsFound$,"_") = 0 then 'You have won the game notice "You have won!" goto [PlayAgain] end if if guessesLeft = 0 then 'GuessesLeft is 0 when we lose. 'You have lost the game notice "You have lost!" goto [PlayAgain] end if goto [waitLoop] sub Pause mil t=time$("milliseconds") while time$("milliseconds")<t+mil wend end sub [PlayAgain] 'notice "play again code" ' Katie - works but cannot select the difficulty of 7 again. Start button doesn't recognize it. ' Katie - will work if you select 10 and or select 10 and then 7. Confirm "Would you like to play again?"; answer$ if answer$ = "yes" then 'notice "your answer was yes!" guessesLeft = 7 print #main.guessesLeftNumber.statictext, str$(guessesLeft) print #main.wordToFind.statictext, "" 'print #main.difficultyLevel.combobox, "" goto [resetGame] else 'notice "your answer was no!" goto [quit.main] end if [difficultyLevel.combobox.select] 'Perform action for the combobox named 'difficultyLevel.combobox' print #main.startGame.btn, "!enable" print #main.difficultyLevel.combobox, "selection? selected$" wordToFind$ = getWord$(val(selected$)) notice wordToFind$ print #main.startGame.btn, "!setfocus" 'main.wordToFind.statictext wordAsFound$ = "" for i = 1 to val(selected$) wordAsFound$ = wordAsFound$ + "_ " next i print #main.wordToFind.statictext, wordAsFound$ goto [waitLoop] [exit.btn.click] 'Perform action for the button named 'exit.btn' goto [quit.main] 'Insert your own code here 'wait 'function getWord$(letterCount) 'Gets a random word of the length letterCount for use in the game function getWord$(letterCount) filename$ = "assets/"+str$(letterCount)+".txt" select case letterCount case 4 open filename$ FOR RANDOM AS #1 LEN=5 FIELD #1,_ ' set up the fields for file opened as #1 4 AS word$,_ ' The record number 1 AS delimeter$ case 5 open filename$ FOR RANDOM AS #1 LEN=6 FIELD #1,_ ' set up the fields for file opened as #1 5 AS word$,_ ' The record number 1 AS delimeter$ case 6 open filename$ FOR RANDOM AS #1 LEN=7 FIELD #1,_ ' set up the fields for file opened as #1 6 AS word$,_ ' The record number 1 AS delimeter$ case 7 open filename$ FOR RANDOM AS #1 LEN=8 FIELD #1,_ ' set up the fields for file opened as #1 7 AS word$,_ ' The record number 1 AS delimeter$ case 8 open filename$ FOR RANDOM AS #1 LEN=9 FIELD #1,_ ' set up the fields for file opened as #1 8 AS word$,_ ' The record number 1 AS delimeter$ case 9 open filename$ FOR RANDOM AS #1 LEN=10 FIELD #1,_ ' set up the fields for file opened as #1 9 AS word$,_ ' The record number 1 AS delimeter$ case 10 open filename$ FOR RANDOM AS #1 LEN=11 FIELD #1,_ ' set up the fields for file opened as #1 10 AS word$,_ ' The record number 1 AS delimeter$ case 11 open filename$ FOR RANDOM AS #1 LEN=12 FIELD #1,_ ' set up the fields for file opened as #1 11 AS word$,_ ' The record number 1 AS delimeter$ case 12 open filename$ FOR RANDOM AS #1 LEN=13 FIELD #1,_ ' set up the fields for file opened as #1 12 AS word$,_ ' The record number 1 AS delimeter$ case 13 open filename$ FOR RANDOM AS #1 LEN=14 FIELD #1,_ ' set up the fields for file opened as #1 13 AS word$,_ ' The record number 1 AS delimeter$ case 14 open filename$ FOR RANDOM AS #1 LEN=15 FIELD #1,_ ' set up the fields for file opened as #1 14 AS word$,_ ' The record number 1 AS delimeter$ case 15 open filename$ FOR RANDOM AS #1 LEN=16 FIELD #1,_ ' set up the fields for file opened as #1 15 AS word$,_ ' The record number 1 AS delimeter$ case 16 open filename$ FOR RANDOM AS #1 LEN=17 FIELD #1,_ ' set up the fields for file opened as #1 16 AS word$,_ ' The record number 1 AS delimeter$ case 17 open filename$ FOR RANDOM AS #1 LEN=18 FIELD #1,_ ' set up the fields for file opened as #1 17 AS word$,_ ' The record number 1 AS delimeter$ case 18 open filename$ FOR RANDOM AS #1 LEN=19 FIELD #1,_ ' set up the fields for file opened as #1 18 AS word$,_ ' The record number 1 AS delimeter$ case 19 open filename$ FOR RANDOM AS #1 LEN=20 FIELD #1,_ ' set up the fields for file opened as #1 19 AS word$,_ ' The record number 1 AS delimeter$ case 20 open filename$ FOR RANDOM AS #1 LEN=21 FIELD #1,_ ' set up the fields for file opened as #1 20 AS word$,_ ' The record number 1 AS delimeter$ case 21 open filename$ FOR RANDOM AS #1 LEN=22 FIELD #1,_ ' set up the fields for file opened as #1 21 AS word$,_ ' The record number 1 AS delimeter$ case 22 open filename$ FOR RANDOM AS #1 LEN=23 FIELD #1,_ ' set up the fields for file opened as #1 22 AS word$,_ ' The record number 1 AS delimeter$ case 23 open filename$ FOR RANDOM AS #1 LEN=24 FIELD #1,_ ' set up the fields for file opened as #1 23 AS word$,_ ' The record number 1 AS delimeter$ case 24 open filename$ FOR RANDOM AS #1 LEN=25 FIELD #1,_ ' set up the fields for file opened as #1 24 AS word$,_ ' The record number 1 AS delimeter$ case 25 open filename$ FOR RANDOM AS #1 LEN=26 FIELD #1,_ ' set up the fields for file opened as #1 25 AS word$,_ ' The record number 1 AS delimeter$ case 26 open filename$ FOR RANDOM AS #1 LEN=27 FIELD #1,_ ' set up the fields for file opened as #1 26 AS word$,_ ' The record number 1 AS delimeter$ case 27 open filename$ FOR RANDOM AS #1 LEN=28 FIELD #1,_ ' set up the fields for file opened as #1 27 AS word$,_ ' The record number 1 AS delimeter$ case 28 open filename$ FOR RANDOM AS #1 LEN=29 FIELD #1,_ ' set up the fields for file opened as #1 28 AS word$,_ ' The record number 1 AS delimeter$ case 29 open filename$ FOR RANDOM AS #1 LEN=30 FIELD #1,_ ' set up the fields for file opened as #1 29 AS word$,_ ' The record number 1 AS delimeter$ end select wordCount = int(lof(#1)/(letterCount+1)) 'print lof(#1),lof(#1)/(letterCount+1), wordCount recordToRead = int(rnd(1)*wordCount)+1 'print "recordToRead=";recordToRead get #1,recordToRead close #1 getWord$ = word$ end function ' Handles click of a letter.btn sub letter.btn.click buttonhandle$ global wordToFind$ buttonLetter$ = mid$(buttonhandle$,7,1) 'notice "The button handle (";buttonLetter$;")is ";buttonhandle$;" Goodbye." print #buttonhandle$, "!hide" ' Search for the letter in the wordToFind$ letterFoundAt = instr(lower$(wordToFind$),lower$(buttonLetter$)) 'notice wordToFind$+" "+buttonLetter$ if letterFoundAt = 0 then ' Letter not found in wordToFind$. call letterNotFound buttonLetter$ else ' Letter found in wordToFind$. call letterFound letterFoundAt,buttonLetter$ end if end sub [letter.btn.hide] for i = 1 to 26 buttonhandle$ = "#main."+chr$(i+64)+".btn" 'notice "hide ";buttonhandle$ print #buttonhandle$, "!hide" next i return [letter.btn.show] for i = 1 to 26 buttonhandle$ = "#main."+chr$(i+64)+".btn" 'notice "show ";buttonhandle$ print #buttonhandle$, "!show" next i return sub letterFound letterFoundAt, buttonLetter$ ' Display letter in word. global wordToFind$ global wordAsFound$ while letterFoundAt > 0 wordAsFoundPosition = letterFoundAt*2-1 wordAsFoundNew$ = "" if wordAsFoundPosition-1 > 0 then _ wordAsFoundNew$ = mid$(wordAsFound$,1,wordAsFoundPosition-1) wordAsFoundNew$ = wordAsFoundNew$ + buttonLetter$ if wordAsFoundPosition+1 < len(wordAsFound$) then _ wordAsFoundNew$ = wordAsFoundNew$ + mid$(wordAsFound$,wordAsFoundPosition+1) wordAsFound$ = wordAsFoundNew$ print #main.wordToFind.statictext, wordAsFound$ letterFoundAt = instr(lower$(wordToFind$),lower$(buttonLetter$),letterFoundAt+1) wend end sub ' wordAsFound$ = wordAsFound$ + "_ " ' print #main.wordToFind.statictext, wordAsFound$ 'letterFoundAt = instr(wordToFind$,buttonLetter$) sub letterNotFound buttonLetter$ ' Take away a guess. global guessesLeft guessesLeft = guessesLeft -1 print #main.guessesLeftNumber.statictext, str$(guessesLeft) 'Katie - Drawing keeps looping, pause in the code to keep the drawing from constantly re-drawing so fast. 'When it wasn't in here, it would go so fast it would lock up the program and crash. if guessesLeft = 6 then gosub [hangman.graphicbox.drawHead] call Pause 600 end if if guessesLeft = 5 then gosub [hangman.graphicbox.drawHead] gosub [hangman.graphicbox.drawTorso] call Pause 600 end if if guessesLeft = 4 then gosub [hangman.graphicbox.drawHead] gosub [hangman.graphicbox.drawTorso] gosub [hangman.graphicbox.drawArmLeft] call Pause 600 end if if guessesLeft = 3 then gosub [hangman.graphicbox.drawHead] gosub [hangman.graphicbox.drawTorso] gosub [hangman.graphicbox.drawArmLeft] gosub [hangman.graphicbox.drawArmRight] call Pause 600 end if if guessesLeft = 2 then gosub [hangman.graphicbox.drawHead] gosub [hangman.graphicbox.drawTorso] gosub [hangman.graphicbox.drawArmLeft] gosub [hangman.graphicbox.drawArmRight] gosub [hangman.graphicbox.drawLegRight] call Pause 600 end if if guessesLeft = 1 then gosub [hangman.graphicbox.drawHead] gosub [hangman.graphicbox.drawTorso] gosub [hangman.graphicbox.drawArmLeft] gosub [hangman.graphicbox.drawArmRight] gosub [hangman.graphicbox.drawLegRight] gosub [hangman.graphicbox.drawLegLeft] call Pause 600 end if goto [letterNotFound.end] [hangman.graphicbox.drawHead] ' Draw head print #main.hangman.graphicbox, "color lightgray; size 1; home; up; north; go 100; turn 270; go 50; up; flush" print #main.hangman.graphicbox, "posxy xVar yVar" 'notice "X:"+str$(xVar)+" Y:"+str$(yVar) print #main.hangman.graphicbox, "color black; size 6; down; circle 25; up; flush" return [hangman.graphicbox.drawTorso] ' Draw torso print #main.hangman.graphicbox, "color lightgray; size 1; turn 270; up; go 25; up; flush" print #main.hangman.graphicbox, "color black; size 6; down; go 80; up; flush" return [hangman.graphicbox.drawArmLeft] ' Draw left arm print #main.hangman.graphicbox, "color lightgray; size 1; turn 180; up; go 60; up; flush" print #main.hangman.graphicbox, "color black; size 6; down; turn 300; go 60; up; flush" return [hangman.graphicbox.drawArmRight] ' Draw right arm print #main.hangman.graphicbox, "color lightgray; size 1; turn 180; up; go 60; up; flush" print #main.hangman.graphicbox, "color black; size 6; down; north; turn 60; go 60; up; flush" return [hangman.graphicbox.drawLegRight] ' Draw right leg print #main.hangman.graphicbox, "color lightgray; size 1; turn 180; up; go 60; up; flush" print #main.hangman.graphicbox, "color lightgray; size 1; north; turn 180; up; go 60; up; flush" print #main.hangman.graphicbox, "color black; size 6; down; north; turn 195; go 80; up; flush" return [hangman.graphicbox.drawLegLeft] ' Draw left leg print #main.hangman.graphicbox, "color lightgray; size 1; turn 180; up; go 80; up; flush" print #main.hangman.graphicbox, "color black; size 6; down; north; turn 165; go 80; up; flush" return [letterNotFound.end] end sub [main.inputLoop] 'wait here for input event wait [quit.main] 'End the program playwave "" unloadbmp ("background") close #main end [startGame.btn.click] 'Perform action for the button named 'btn_StartGame' guessesLeft = 7 print #main.guessesLeftNumber.statictext, str$(guessesLeft) gosub [letter.btn.show] goto [waitLoop] 'statictext #main.guessesLeftNumber.statictext, "7", 460, 282, 9, 20