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/ED/ |
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, 20, 20 ' End GUI objects code ' Open and setup #main open "Hangman" for window as #main ' Play some music playwave "assets\music.wav", loop [startGame] guessesLeft = 7 print #main.guessesLeftNumber.statictext, str$(guessesLeft) wordFound$ = "_" 'stop win before start ' 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] counter = 0 [waitloop] scan counter = counter+1 print guessesLeft,counter if guessesLeft = 0 then notice "You lose!" goto [askToPlayAgain] end if if instr(wordFound$,"_") = 0 then notice "You won!" goto [askToPlayAgain] end if goto [waitloop] [askToPlayAgain] 'put our code here! wait [difficultyLevel.combobox.select] 'Perform action for the combobox named 'difficultyLevel.combobox' print #main.startGame.btn, "!enable" print #main.difficultyLevel.combobox, "selection? selected$" numberOfLettersInWord = val(selected$) wordToFind$ = getWord$(numberOfLettersInWord) notice wordToFind$ print #main.startGame.btn, "!setfocus" ' set wordFound$ and display underscores wordFound$ = "" for i = 1 to numberOfLettersInWord wordFound$ = wordFound$ + "_ " next i print #main.wordToFind.statictext, wordFound$ goto [waitloop] [exit.btn.click] 'Perform action for the button named 'exit.btn' goto [quit.main] 'Insert your own code here '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 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" end sub sub 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" end sub sub 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" end sub sub 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" end sub sub 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" end sub sub 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" end sub ' 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$ 'notice "wordToFind$="+wordToFind$ letterFoundAt = instr(lower$(wordToFind$),lower$(buttonLetter$)) 'notice str$(letterFoundAt)+" "+buttonLetter$+" ["+wordToFind$+"]" 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$ global wordFound$ 'notice str$(letterFoundAt)+" "+buttonLetter$+" ["+wordFound$+"]" ' Display letter in word. [nextLetter] wordFoundPosition = letterFoundAt*2-1 wordFound$ = mid$(wordFound$,1,wordFoundPosition-1) + buttonLetter$ + mid$(wordFound$,wordFoundPosition+1) print #main.wordToFind.statictext, wordFound$ letterFoundAt = instr(lower$(wordToFind$),lower$(buttonLetter$),letterFoundAt+1) if letterFoundAt > 0 then goto [nextLetter] ' Check if won game. End game if they did. end sub sub letterNotFound buttonLetter$ global guessesLeft ' Display part of the body. SELECT CASE guessesLeft CASE 7 call hangman.graphicbox.drawHead CASE 6 call hangman.graphicbox.drawTorso CASE 5 call hangman.graphicbox.drawArmLeft CASE 4 call hangman.graphicbox.drawArmRight CASE 3 call hangman.graphicbox.drawLegRight CASE 2 call hangman.graphicbox.drawLegLeft CASE 1 'Draw noose? CASE 0 END SELECT ' Take away a guess. guessesLeft = guessesLeft-1 print #main.guessesLeftNumber.statictext, str$(guessesLeft) ' Check if last guess. End game if it is. This is done by [waitloop] end sub [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] goto [waitloop]