Sign in to follow this  
Followers 0
AlmarM

AutoIt Hangman

6 posts in this topic

Hi,

With great thanks to Manadar, I made a Hangman in AutoIt.

All files include in .rar

;)

AutoIt Hangman.rar


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

With great thanks to Manadar, I made a Hangman in AutoIt.

All files include in .rar

;)

Arghh. I'm hung.

I got: _I_MO

I like it!

Edited by czardas

Share this post


Link to post
Share on other sites

Ran it twice, got hung both times.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I took some random words from internet that would be "hard" to guess. Soooo... ;)


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

I had a play with your Hangman script.

Ended up only using your word list file as a string at the beginning of this stand alone script.

It is a really good list of words - tricky.

Opt("MustDeclareVars", 1)   ;0=no, 1=require pre-declare

;#include <GUIConstantsEx.au3>
Global Const $GUI_GR_LINE = 2
Global Const $GUI_GR_MOVE = 6
Global Const $GUI_GR_COLOR = 8
Global Const $GUI_GR_ELLIPSE = 12
Global Const $GUI_GR_PENSIZE = 24

Local $text = "abbey,abruptly,affix,askew,axiom,azure,bagpipes,bandwagon,banjo,bayou,bikini," & _
        "blitz,bookworm,boxcar,boxful,buckaroo,buffalo,buffoon,cobweb,croquet,daiquiri,disavow," & _
        "duplex,dwarves,equip,exodus,fishhook,fixable,foxglove,galaxy,galvanize,gazebo,gizmo," & _
        "glowworm,guffaw,haiku,haphazard,hyphen,icebox,injury,ivory,ivy,jaundice,jawbreaker," & _
        "jaywalk,jazzy,jigsaw,jiujitsu,jockey,jovial,joyful,juicy,jumbo,kazoo,keyhole,khaki," & _
        "kilobyte,kiosk,kiwifruit,knapsack,larynx,luxury,marquis,megahertz,microwave,mystify," & _
        "nightclub,nowadays,numbskull,ovary,oxidize,oxygen,pajama,peekaboo,pixel,pizazz," & _
        "pneumonia,polka,quartz,quiz,quorum,razzmatazz,rhubarb,rickshaw,schizophrenia,sphinx," & _
        "spritz,squawk,subway,swivel,topaz,unknown,unworthy,unzip,uptown,vaporize,vixen,vodka," & _
        "vortex,walkway,waltz,wavy,waxy,wheezy,whiskey,whomever,wimpy,wizard,woozy,xylophone," & _
        "yachtsman,yippee,youthful,zephyr,zigzag,zilch,zodiac,zombie"
Local $file, $Line1, $Line2, $iCount = -1, $iMiss = 0, $sMiss

$file = StringSplit($text, ",")
$Line2 = $file[Random(1, $file[0], 1)]
;ConsoleWrite($Line2 & @CRLF)

$Line1 = StringRegExpReplace(StringFormat("%" & StringLen($Line2) & "s", " "), ".", "_")

While $Line2 <> $Line1
    Local $InpB, $iStart = 1, $occurrence = 1
    $iCount += 1
    $InpB = InputBox("HangMan Mk2 - Guess a letter", $Line1 & @CRLF & @CRLF & "Number of tries: " & _
            $iCount & @CRLF & @CRLF & "Number of Misses: " & $iMiss & @CRLF & $sMiss)
    If @error = 1 Then Exit
    If StringInStr($Line2, $InpB, 0) = 0 Then
        $iMiss += 1
        If StringInStr($sMiss, $InpB) = 0 Then $sMiss &= StringUpper($InpB) & " "
        DrawHMan($iMiss)
        If $iMiss = 10 Then
            MsgBox(0, "tHE eND", "Hung" & @CRLF & 'The word was "' & $Line2 & '"')
            Exit
        EndIf
    EndIf

    While StringInStr($Line2, $InpB, 0, $occurrence) <> 0
        $iStart = StringInStr($Line2, $InpB, 0, $occurrence)
        $Line1 = StringLeft($Line1, $iStart - 1) & StringUpper($InpB) & StringRight($Line1, StringLen($Line2) - $iStart)
        $occurrence += 1
    WEnd
WEnd

MsgBox(0, "tHE eND", "Not hung - success" & @CRLF & 'The word was "' & $Line2 & '"' & _
        @CRLF & @CRLF & "Number of tries: " & $iCount + 1 & @CRLF & @CRLF & _
        "Number of Misses: " & $iMiss & @CRLF & $sMiss)


Func DrawHMan($Op)
    Local $child, $idGraphic
    If WinExists("Hangman Progress") Then GUIDelete($child)
    $child = GUICreate("Hangman Progress", 150, 300, @DesktopWidth / 2 + 140, @DesktopHeight / 2 - 150, BitOR(0x00000080, 0x00000008))
    $idGraphic = GUICtrlCreateGraphic(-2, -2, 150, 280)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
    If $Op >= 1 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 2, 255) ; Base
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 130, 255)
    EndIf
    If $Op >= 2 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10) ; Upright
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 255)
    EndIf
    If $Op >= 3 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10) ; Horiz. beam
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 95, 10)
    EndIf
    If $Op >= 4 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 10) ; rope
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 85, 50)
    EndIf
    If $Op >= 5 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 70, 255) ; Head
        GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 70, 50, 30, 30)
    EndIf
    If $Op >= 6 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 80) ; Body
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 85, 180)
    EndIf
    If $Op >= 7 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 180) ; Right Leg
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 120, 215)
    EndIf
    If $Op >= 8 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 180) ; Left leg
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 50, 215)
    EndIf
    If $Op >= 9 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 105) ; Right arm
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 120, 140)
    EndIf
    If $Op >= 10 Then
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 85, 105) ; Left arm
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, 50, 140)
    EndIf
    GUISetState()
EndFunc ;==>DrawHMan

Share this post


Link to post
Share on other sites

Yeah, you could do it that way, I just thought to keep it simple. :D


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0