FriendsFade Posted May 16, 2011 Posted May 16, 2011 This is my take on a Hangman game and I choose not to release the source for now as it still a semi-private script of mine Enjoy Download!
sleepydvdr Posted May 26, 2011 Posted May 26, 2011 Nice game. Suggestions: I suggest encrypting the word list so it's not so easy to cheat. Also, I ran this in a VM machine because you didn't post the code (unknown executable). No problem there, but my VM has a resolution of 800x600. That is a reasonable resolution for older computers and your game almost fit in that screen, but not quite all of it fit. Trim it down just a little so it can fit on computers with lower screen resolutions. Game suggestions: give a hint to give the user a direction to think. Example: let's say the word you are guessing for is "The Matrix"; Show a clue that would say: "It has you". Or something along those lines. Also, how about showing the word if you can't figure it out? It would be a disappointment to spend ten minutes trying to guess a word just to see "you lose" and not get to see what it was. Nice game, overall. I wouldn't mind seeing it when you refine it a little more. #include <ByteMe.au3>
FriendsFade Posted May 28, 2011 Author Posted May 28, 2011 (edited) Nice game. Suggestions: I suggest encrypting the word list so it's not so easy to cheat. Also, I ran this in a VM machine because you didn't post the code (unknown executable). No problem there, but my VM has a resolution of 800x600. That is a reasonable resolution for older computers and your game almost fit in that screen, but not quite all of it fit. Trim it down just a little so it can fit on computers with lower screen resolutions. Game suggestions: give a hint to give the user a direction to think. Example: let's say the word you are guessing for is "The Matrix"; Show a clue that would say: "It has you". Or something along those lines. Also, how about showing the word if you can't figure it out? It would be a disappointment to spend ten minutes trying to guess a word just to see "you lose" and not get to see what it was. Nice game, overall. I wouldn't mind seeing it when you refine it a little more. I don't plan on working on this script anymore it was just made to pass the time...It does need a few improvements Anyways ill post the source now and hopefully I will get some more feed back expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Icon.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Misc.au3> #Include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Text , $Word , $Hang, $Blanks , $Letter[100] , $Labels[100] $Hang = 0 $Width = 864 $Height = 500 $Font_Size = 20 $Font_Name = "Jokerman" $Resource = @ScriptDir & "\Resources" _Singleton(@ScriptName) $Hangman = GUICreate("Hangman", $Width , $Height , Default, Default, $WS_POPUP + $WS_THICKFRAME);, $WS_EX_TOPMOST) GUISetBkColor(0xD0BE68, $Hangman) $Background = GUICtrlCreatePic($Resource & "\Background.bmp" , 0, 0, $Width, $Height) $Exit = GUICtrlCreatePic($Resource & "\Exit.bmp" , $Width -40, 0, 40, 40) $Head = GUICtrlCreatePic("" , 115, 180, 100, 64) $Torso = GUICtrlCreatePic("" , 145, 244, 40, 61) $Left_Arm = GUICtrlCreatePic("" , 127, 250, 18, 41) $Right_Arm = GUICtrlCreatePic("" , 185, 250, 18, 41) $Pants = GUICtrlCreatePic("" , 147, 305, 36, 20) $Left_Leg = GUICtrlCreatePic("" , 139, 325, 25, 35) $Right_Leg = GUICtrlCreatePic("" , 166, 325, 25, 35) ;$Text = GUICtrlCreateLabel("" , 0 , 50 , $Width, 50, $SS_CENTER) ;GUICtrlSetFont($Text, $Font_Size, 800, 0, $Font_Name) ;GUICtrlSetBkColor($Text, $GUI_BKCOLOR_TRANSPARENT) $Label_X = 0 $Label_Y = 50 For $i = 1 To StringLen($Word) Step +1 $Labels[$i] = GUICtrlCreateLabel("_" , $Label_X , $Label_Y , 50, 50) GUICtrlSetFont($Labels[$i], $Font_Size, 800, 0, $Font_Name) GUICtrlSetBkColor($Labels[$i], $GUI_BKCOLOR_TRANSPARENT) $Label_X += 50 Next $Word_Count = GUICtrlCreateLabel("" , 0 , 145, 180, 25, $SS_CENTER) GUICtrlSetFont($Word_Count, 12, 800, 0, $Font_Name) ;12 GUICtrlSetColor($Word_Count, 0x00FF00) GUICtrlSetBkColor($Word_Count, $GUI_BKCOLOR_TRANSPARENT) $Gold = GUICtrlCreateLabel("$100" , 0 , 370, 265, 30, $SS_CENTER) GUICtrlSetFont($Gold, $Font_Size, 800, 0, $Font_Name) GUICtrlSetColor($Gold, 0x00FF00) GUICtrlSetBkColor($Gold, $GUI_BKCOLOR_TRANSPARENT) $Letter_X = 0 $Letter_Y = $Height -32 For $i = 65 To 90 Step +1 $Letter[$i] = GUICtrlCreatePic($Resource & "\" & Chr($i) & ".bmp", $Letter_X, $Letter_Y, 32, 32) $Letter_X += 32 Next $Hint = GUICtrlCreatePic($Resource & "\Hint.bmp" , $Width -32 , $Letter_Y, 32, 32) GUICtrlSetColor($Hint, 0x000000) GUICtrlSetBkColor($Hint, 0xD0BE68) GUISetState(@SW_HIDE) GUICtrlSetState($Background , $GUI_DISABLE) _New_Game() GUIRegisterMsg($WM_SETCURSOR, "_Cursor") $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $Resource & "\Skull.cur") DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Hangman, "int", 1000, "long", 0x00080000) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NCHITTEST, "_No_Resize") While 1 $Msg = GUIGetMsg() Switch $Msg Case $Exit DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Hangman, "int", 1000, "long", 0x00090000) Exit Case $Letter[65] ;To $Letter[90] _Use_Letter(65 , $Word) Case $Letter[66] _Use_Letter(66 , $Word) Case $Letter[67] _Use_Letter(67 , $Word) Case $Letter[68] _Use_Letter(68 , $Word) Case $Letter[69] _Use_Letter(69 , $Word) Case $Letter[70] _Use_Letter(70 , $Word) Case $Letter[71] _Use_Letter(71 , $Word) Case $Letter[72] _Use_Letter(72 , $Word) Case $Letter[73] _Use_Letter(73 , $Word) Case $Letter[74] _Use_Letter(74 , $Word) Case $Letter[75] _Use_Letter(75 , $Word) Case $Letter[76] _Use_Letter(76 , $Word) Case $Letter[77] _Use_Letter(77 , $Word) Case $Letter[78] _Use_Letter(78 , $Word) Case $Letter[79] _Use_Letter(79 , $Word) Case $Letter[80] _Use_Letter(80 , $Word) Case $Letter[81] _Use_Letter(81 , $Word) Case $Letter[82] _Use_Letter(82 , $Word) Case $Letter[83] _Use_Letter(83 , $Word) Case $Letter[84] _Use_Letter(84 , $Word) Case $Letter[85] _Use_Letter(85 , $Word) Case $Letter[86] _Use_Letter(86 , $Word) Case $Letter[87] _Use_Letter(87 , $Word) Case $Letter[88] _Use_Letter(88, $Word) Case $Letter[89] _Use_Letter(89 , $Word) Case $Letter[90] _Use_Letter(90 , $Word) Case $Hint SoundPlay($Resource & "\Hint.ogg") _Hint($Word) EndSwitch WEnd Func _Gen_Word() $Return_Word = FileReadLine($Resource & "\Word List.txt" , Random(1 , _FileCountLines($Resource & "\Word List.txt") , 1)) Return $Return_Word EndFunc Func _Use_Letter($Use_Letter, $Use_Word) GUICtrlSetState($Letter[$Use_Letter] , $GUI_DISABLE) GUICtrlSetImage($Letter[$Use_Letter] , $Resource & "\Blank.bmp") $Gen_Length = StringLen($Use_Word) $Find_Letter = StringInStr($Use_Word, Chr($Use_Letter)) If $Find_Letter Then $Letter_Count = 0 Do $Letter_Count = $Letter_Count +1 $Replace_Letter = StringInStr($Use_Word, Chr($Use_Letter), Default, $Letter_Count) GUICtrlSetData($Labels[$Replace_Letter], Chr($Use_Letter)) Until $Letter_Count = $Gen_Length _Check_Win() Else _Hang() GUISetState(@SW_SHOW, $Hangman) EndIf EndFunc Func _Check_Win() $Gen_Length = StringLen($Word) $Read_Labels = "" For $i = 1 To $Gen_Length $Read_Labels = $Read_Labels & GUICtrlRead($Labels[$i]) Next If $Read_Labels = $Word Then $Gold_Amount = StringTrimLeft(GUICtrlRead($Gold), 1) GUICtrlSetData($Gold, "{:content:}quot; & $Gold_Amount +100) For $i = 65 To 90 GUICtrlSetState($Letter[$i], $GUI_DISABLE) Next Sleep(2000) ;Show Word!!! $Gen_Length = StringLen($Word) For $i = 1 To $Gen_Length GUICtrlDelete($Labels[$i]) Next GUICtrlSetState($Hint, $GUI_DISABLE) $Word = "Congratulations!" $Label_X = 0 $Label_Y = 50 For $i = 1 To StringLen($Word) Step +1 $Labels[$i] = GUICtrlCreateLabel(StringMid($Word, $i, 1) , $Label_X , $Label_Y , 50, 50) GUICtrlSetFont($Labels[$i], $Font_Size, 800, 0, $Font_Name) GUICtrlSetBkColor($Labels[$i], $GUI_BKCOLOR_TRANSPARENT) $Label_X += 50 Next SoundPlay($Resource & "\Won.wav" , 1) _New_Game() EndIf EndFunc Func _Hang() SoundPlay($Resource & "/No.wav") $Hang +=1 If $Hang = 1 Then GUICtrlSetImage($Head, $Resource & "\Head.bmp") ElseIf $Hang = 2 Then GUICtrlSetImage($Torso, $Resource & "\Torso.bmp") ElseIf $Hang = 3 Then GUICtrlSetImage($Left_Arm, $Resource & "\Left Arm.bmp") ElseIf $Hang = 4 Then GUICtrlSetImage($Right_Arm, $Resource & "\Right Arm.bmp") ElseIf $Hang = 5 Then GUICtrlSetImage($Pants, $Resource & "\Pants.bmp") ;New Skin Required. GUICtrlSetImage($Left_Leg, $Resource & "\Left Leg.bmp") ElseIf $Hang = 6 Then GUICtrlSetImage($Pants, $Resource & "\Pants.bmp") ;New Skin Required. GUICtrlSetImage($Right_Leg, $Resource & "\Right Leg.bmp") Else $Gold_Amount = StringTrimLeft(GUICtrlRead($Gold), 1) GUICtrlSetData($Gold, "{:content:}quot; & $Gold_Amount -50) For $i = 65 To 90 GUICtrlSetState($Letter[$i], $GUI_DISABLE) Next Sleep(2000) ;Show Word!!! $Gen_Length = StringLen($Word) For $i = 1 To $Gen_Length GUICtrlDelete($Labels[$i]) Next GUICtrlSetState($Hint, $GUI_DISABLE) $Word = "Game Over!" $Label_X = 0 $Label_Y = 50 For $i = 1 To StringLen($Word) Step +1 $Labels[$i] = GUICtrlCreateLabel(StringMid($Word, $i, 1) , $Label_X , $Label_Y , 50, 50) GUICtrlSetFont($Labels[$i], $Font_Size, 800, 0, $Font_Name) GUICtrlSetBkColor($Labels[$i], $GUI_BKCOLOR_TRANSPARENT) $Label_X += 50 Next SoundPlay($Resource & "\Lost.wav" , 1) _New_Game() EndIf EndFunc Func _Hint($iHint) GUICtrlSetState($Hint, $GUI_DISABLE) $Gen_Length = StringLen($iHint) $i = 0 Do $i +=1 $Read_Labels = GUICtrlRead($Labels[$i]) If $Read_Labels = "_" Then $Return_Hint = StringMid($Word, $i , 1) ExitLoop EndIf Until $i = $Gen_Length If $Return_Hint = "" Then MsgBox(0 , "No Hint" , "Hint unavailable at present time.") Else $Gold_Amount = StringTrimLeft(GUICtrlRead($Gold), 1) If $Gold_Amount >= 1000 Then GUICtrlSetData($Gold, "{:content:}quot; & $Gold_Amount -1000) MsgBox(0 , "Your Hint is" , StringUpper($Return_Hint)) Else MsgBox(0 , "No Hint" , "Hint cost 1000 Gold.") EndIf EndIf EndFunc Func _New_Game() $Hang = 0 For $i = 65 To 90 GUICtrlSetState($Letter[$i], $GUI_DISABLE) Next $Gen_Length = StringLen($Word) For $i = 1 To $Gen_Length GUICtrlDelete($Labels[$i]) Next GUICtrlSetImage($Head, "") GUICtrlSetImage($Torso, "") GUICtrlSetImage($Left_Arm, "") GUICtrlSetImage($Right_Arm, "") GUICtrlSetImage($Pants, "") ;New Skin Required. GUICtrlSetImage($Left_Leg, "") GUICtrlSetImage($Pants, "") ;New Skin Required. GUICtrlSetImage($Right_Leg, "") GUICtrlSetState($Hint, $GUI_ENABLE) For $i = 65 To 90 GUICtrlSetState($Letter[$i], $GUI_ENABLE) GUICtrlSetImage($Letter[$i], $Resource & "\" & Chr($i) & ".bmp") Next $Word = _Gen_Word() $Label_X = 0 $Label_Y = 50 For $i = 1 To StringLen($Word) Step +1 $Labels[$i] = GUICtrlCreateLabel("_" , $Label_X , $Label_Y , 50, 50) GUICtrlSetFont($Labels[$i], $Font_Size, 800, 0, $Font_Name) GUICtrlSetBkColor($Labels[$i], $GUI_BKCOLOR_TRANSPARENT) $Label_X += 50 Next GUICtrlSetData($Word_Count , "Letter Count = " & StringLen($Word)) EndFunc Func _Cursor($Cur_Win) If $Cur_Win = $Hangman Then DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndIf EndFunc Func _No_Resize() Return "No Resize Allowed" EndFunc Edited May 28, 2011 by FriendsFade
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