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/EM/ |
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 "startBackground", "assets\startBackground.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, 20, 20 ' 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 startBackground -40 -70" ' Disable the startGame.btn. print #main.startGame.btn, "!disable" ' 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 [opening.screen] 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" print #main.difficultyLevel.combobox,"disable" 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 sub letter.btn.click buttonhandle$ global wordToFind$ global buttonLetter$ buttonLetter$ = mid$(buttonhandle$,7,1) buttonLetter$ = lower$(buttonLetter$) 'notice "The button handle (";buttonLetter$;")is ";buttonhandle$;" Goodbye." print #buttonhandle$, "!hide" ' Search for the letter in the wordToFind$ letterFoundAt = instr(wordToFind$,buttonLetter$) if letterFoundAt = 0 then global guessedWrong guessedWrong = (guessedWrong + 1) global guessesLeft guessesLeft = (7 - guessedWrong) ' Letter not found in wordToFind$. call letterNotFound buttonLetter$ else ' Letter found in wordToFind$. call letterFound buttonLetter$ end if end sub [opening.screen] for i = 1 to 26 buttonhandle$ = "#main."+chr$(i+64)+".btn" 'notice "hide ";buttonhandle$ print #buttonhandle$, "!hide" next i ' hide guesses left print #main.guessesLeftLabel.statictext,"!hide" print #main.guessesLeftNumber.statictext,"!hide" 'hide wordtofind print #main.wordToFind.statictext,"!hide" return [game.screen] for i = 1 to 26 buttonhandle$ = "#main."+chr$(i+64)+".btn" 'notice "show ";buttonhandle$ print #buttonhandle$, "!show" next i 'show guesses left print #main.guessesLeftLabel.statictext,"!show" print #main.guessesLeftNumber.statictext,"!show" 'show wordtofind print #main.wordToFind.statictext,"!show" 'disable start background unloadbmp ("startBackground") 'use new background loadbmp "background", "assets\background.bmp" print #main.hangman.graphicbox, "drawbmp background -40 -70" ' 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" playwave "assets\bells.wav" return sub letterFound buttonLetter$ playwave "assets/correctGuess.wav", sync ' Display letter in word. ' Check if won game. End game if they did. end sub sub letterNotFound buttonLetter$ ' Take away a guess. #main.guessesLeftNumber.statictext, guessesLeft if guessesLeft = 6 then ' 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" end if if guessesLeft = 5 then 'display 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" end if if guessesLeft = 4 then ' 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" end if if guessesLeft = 3 then ' 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" end if if guessesLeft = 2 then ' Draw left 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" end if if guessesLeft = 1 then ' 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" end if playwave "assets/wrongGuess.wav", sync if guessesLeft = 0 then playwave "assets/thud.wav", sync playwave "assets/gameOver.wav", sync notice "You lose. Better luck next time." end if 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' gosub [game.screen] wait 'list of changes made 'took away a guess when guess was wrong 'displayed a part of the body for each wrong guess 'when the game was lost, displayed a notice 'disabled the diffuculty level combo box after it was initially pressed so that the user cannot press it again while the game is active 'displayed a different opening screen prior to the user hitting the start button 'put multiple sound effects in