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.04.24/KM/ |
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) = "7" 'replace with loop that looks for files difficultyLevel$(2) = "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, "7", 460, 282, 9, 20 'sets some starting values for variables GuessesLeft = 7 ' End GUI objects code ' Open and setup #main open "Hangman" for window as #main ' Play some music playwave "assets\music.wav", loop ' 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] wait [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" wait [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 'added repeat functionality from other program -Katie function repeat$(stringToRepeat$,repeatNumber) newString$ = "" for i = 1 to repeatNumber newString$ = newString$ + stringToRepeat$ next i repeat$ = newString$ end function ' Handles click of a letter.btn sub letter.btn.click buttonhandle$ global wordToFind$ buttonLetter$ = mid$(buttonhandle$,7,1) wordlength = len(wordToFind$) ourword$ = repeat$("_ ",wordlength) 'below notice confirms button letter and button pushed 'notice "The button handle (";buttonLetter$;")is ";buttonhandle$;" Goodbye." print #buttonhandle$, "!hide" ' Search for the letter in the wordToFind$ letterFoundAt = instr(upper$(wordToFind$),buttonLetter$,1) 'notices below are just for debugging - Katie 'notice buttonLetter$ notice wordToFind$ 'notice letterFoundAt if letterFoundAt = 0 then call letterNotFound buttonLetter$ else ' Letter found in wordToFind$. call letterFound buttonLetter$ 'the below code inserts the letter we guessed into the spaces shown at the bottom of the gallows 'then replaces it, issues with not keeping the original letters if they are in the word 'it replaces the whole thing and only shows one letter. Any letter position after 3 adds more "_ " 'to the display at the bottom of the gallows. The higher the position the more spaces it adds. ourword$ = mid$(ourword$,1,((letterFoundAt*2)-1)-1) + _ upper$(buttonLetter$) + _ mid$(ourword$,(int(letterFoundAt/2)+2)+1) end if print #main.wordToFind.statictext, ourword$ 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 buttonLetter$ ' Display letter in word. ''put this in the letter.btn.click under letter found call. Could not get it to work as well in ''the sub routine and don't know how to fix it. -Katie ' the following notice confirms which sub routine we are in notice "you are in letter found subroutine" global wordToFind$ ' Check if won game. End game if they did. end sub sub letterNotFound buttonLetter$ 'the following notice confirms which sub routine we are in notice "you are in letter not found sub" ' Take away a guess. global GuessesLeft GuessesLeft = GuessesLeft - 1 'notice just checks to see value of guesses left notice "this is your guesses left: ";GuessesLeft 'Depending on the guesses left the appropriate body parts will display. If last guess then they lost. if GuessesLeft = 6 then gosub [hangman.graphicbox.drawHead] wait end if if GuessesLeft = 5 then gosub [hangman.graphicbox.drawTorso] wait end if if GuessesLeft = 4 then gosub [hangman.graphicbox.drawArmLeft] wait end if if GuessesLeft = 3 then gosub [hangman.graphicbox.drawArmRight] wait end if if GuessesLeft = 2 then gosub [hangman.graphicbox.drawLegRight] wait end if if GuessesLeft = 1 then gosub [hangman.graphicbox.drawLegLeft] wait end if 'this one is iffy could take out. lets the user get one more chance after the body is drawn. if GuessesLeft = 0 then Notice "You Have Been Hung!" 'goto [playagain] --- doesn't work yet program errors out and closes. 'wait end if [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" print #main.guessesLeftNumber.statictext, GuessesLeft 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" print #main.guessesLeftNumber.statictext, GuessesLeft 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" print #main.guessesLeftNumber.statictext, GuessesLeft 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" print #main.guessesLeftNumber.statictext, GuessesLeft 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" print #main.guessesLeftNumber.statictext, GuessesLeft 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" print #main.guessesLeftNumber.statictext, GuessesLeft return 'this needs to get fixed to go to the appropriate places work on per phone conversation with jim. '[YesorNo] ' asks the user if they would like to play again 'Confirm "Would you like to play again?"; answer$ 'if answer$ = "no" then goto [quit.main] 'if answer$ = "yes" then goto [difficultyLevel.combobox.select] 'this is not done yet code doesn't go to branch labels - errors out end sub 'doesn't work. is going to be either a branchlabel, function, or sub routine to deal with the 'users response to playing again or not. [playagain] Confirm "Would you like to play again?"; answer$ if answer$ = "no" then notice "your answer was no!" else notice "your answer was yes!" end if wait 'if answer$ = "yes" then goto [difficultyLevel.combobox.select] [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' gosub [letter.btn.show] wait