cdkid Posted May 25, 2006 Share Posted May 25, 2006 (edited) I have a quick question. I'm making a hangman game & I need a way to check constantly for any letter being pressed. This is my code so far (I'm gonna neaten it up & make some changes, this is kinda the rough draft) expandcollapse popupdim $words[79] = ["Apple","Oderberg","accomplishments","advisee","aloes","antigens","arrives","audiologist","banally","beetles", _ "biscuits","bonus","brindle","buttock's","cathode","choring","codification's","compounder","consulate's","counsel's","culmination", _ "decompile","derivable","diplomat","distill","drum's","embellishes","equate","expectations","father's","flickered","frailer","gem", _ "grange","handbooks","hijacker","hustles","inaudible","infuriates","interferer","jaunty","landmark","likings","lynx's","mead", _ "miracle's","mousing","niches","offensive","overnighters","paten","pewter","pocketbook","prejudged","promulgation","quarries", _ "realm","refelled","renounces","restroom's","rods","saying","semaphores","shrewdest","slicker","southing","stallings","strengthening", _ "sulkies","system","testifiers","tomb","trigonometry","unchallenged","unjamming","updater","village's","webs","wordiness"] #include <Misc.au3> Global $TheWord, $MainGui, $letters[1], $play = false SplashImageOn("HangMan v1.0 By Cdkid", @scriptdir & "\hangman.gif") global $l = 50, $t = 300 Splashoff() $MainGui = GuiCreate("Hangman!") GuiSetState() GuiSetBkColor(0x9C6Cf3) $infolabel = GuiCtrlCreateLabel("The classic HangMan game, use your keyboard to guess letters." & @crlf & @tab & @tab & "Click `Help` for more info.", 50, 10) $solve = GuiCtrlCreateButton("Solve", 0, 0) $play = GuiCtrlCreateButton("Play!", 10, 100, 100, 30) $quit = GuiCtrlCreateButton("Quit.", 10, 150, 100, 30) $help = GuiCtrlCreateButton("Help", 10, 200, 100, 30) While 1 #region - GUI SwitchLoop Switch GUIGetMsg() Case -3 Exit case $solve _Solve() Case $help MsgBox(0, "Help", "This is the traditional hangman game, press letters on your keyboard to guess a letter. You get 9 chances. Press Hint to" & _ "get the first letter of the word, but also add one more body part. SAVE THE HANGMAN!") Case $quit Exit Case $play _BeginHangMan() EndSwitch #endregion WEnd Func _BeginHangMan() $play = true $l = 10 GuiCtrlDelete($play) GuiCtrlDelete($help) GuiCtrlDelete($quit) GuiCtrlDelete($infolabel) $theword = $words[Random(0, 78, 1)] redim $letters[StringLen($TheWord) + 1][2] For $i = 1 to StringLen($TheWord) If StringMid($TheWord, $i, 1) = "'" Then GuiCtrlCreateLabel("'", $l, $t) $l = $l + 20 ElseIf StringMid($TheWord, $i, 1) = " " Then guictrlcreatelabel("(SPACE)",$l, $t) $l = $l + 20 Else $letters[$i][0] = guictrlcreatelabel("____", $l, $t, 15, 20) $letters[$i][1] = StringMid($TheWord, $i, 1) GuiCtrlSetBkColor(-1, 0xFFFFFF) $l = $l + 20 EndIf Next EndFunc Func _Solve() for $i = 0 to UBound($letters, 1) - 1 GuiCtrlSetData($letters[$i][0], $letters[$i][1]) Next sleep(5000) for $i = 0 to UBound($letters, 1) - 1 GuiCtrlDelete($letters[$i][0]) Next _BeginHangMan() EndFunc EDIT: Sorry, nevermind I found my problem... disregard this post Edited May 25, 2006 by cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now