Jump to content

A little blackjackclone..


Baku
 Share

Recommended Posts

I think this is a good idea to introduce newcommers with the random-function.

#include <GuiConstants.au3>
GUICreate("WhiteJoe", 245, 65, (@DesktopWidth - 245) / 2, (@DesktopHeight - 105) / 2, $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_EX_STATICEDGE)

HotKeySet("{ESC}", "_exit")

Func _exit()
    Exit
EndFunc  ;==>_exit

$points = "0"

$Button_3 = GUICtrlCreateButton("Take", 10, 10, 110, 20)
$Button_4 = GUICtrlCreateButton("Stop", 130, 10, 100, 20)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_3
            get()
        Case $msg = $Button_4
            computer()
        Case Else
        ;;;
    EndSelect
WEnd
Exit


Func get()
    $add = Random(1, 11, 1)
    $points = $add + $points
    If $points > 21 Then
        $msgbox = MsgBox(4 + 32, "You loose!", $points & " Points. - " & "You loose!" & @LF & "New game?")
        Select
            Case $msgbox = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
        $points = "0"
    ElseIf $points = 1 Then
        MsgBox(64, "Points", "1 Point")
    Else
        MsgBox(64, "Points", $points & " points")
    EndIf
    Return $points
EndFunc  ;==>get

Func computer()
    $compoints = Random(14, 24, 1)
    
    If $compoints > $points And $compoints < 22 Then
        $msgbox = MsgBox(4 + 32, "Computer wins!", "Computer wins with " & $compoints & " points. (You have " & $points & " points)" & @LF & "New game?")
        Select
            Case $msgbox = 7
                Exit
            Case Else
                $punkte = "0"
        EndSelect
    ElseIf $compoints = $points Then
        $msglos = MsgBox(4 + 32, "Draw!", "Draw with " & $compoints & " points." & @LF & "New game?")
        Select
            Case $msglos = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
    Else
        $msgwin = MsgBox(4 + 32, "You win!", "You win with " & $points & " points. (Computer has " & $compoints & " points)" & @LF & "New game?")
        Select
            Case $msgwin = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
    EndIf
EndFunc  ;==>computer
Edited by Baku
Link to comment
Share on other sites

Good luck with that! :)

It will be great to see how far this gets. If you're interested in working on a GUI then look for cards.dll somewhere in your Windows folder tree -- it contains bitmaps of the cards and some nice backs too.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...