Jump to content

Slot Machine


Recommended Posts

I have already did a search and found slot machines in the example scripts but they are more complicated than I want them to be.

This is the code I got so far and I was just wondering if this works how I want it to more or less I just need a second eye to help spot any errors.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $Wheel[4]
$Slots = GUICreate("Form1", 600, 600)
$Wheel[1] = GUICtrlCreatePic("1.jpg", 0 , 0 , 200 , 200)
$Wheel[2] = GUICtrlCreatePic("1.jpg", 200 , 0 , 200 , 200)
$Wheel[3] = GUICtrlCreatePic("1.jpg", 400 , 0 , 200 , 200)
$Spin = GUICtrlCreateButton("Spin" , 0 , 200 , 600 , 20)
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Spin
            _Spin()
    EndSwitch
WEnd

Func _Spin()
    $Delay = 0
    Sleep($Delay)
    $iWheel = 1
    Do
        $Random = Random(1 , 4 , 1)
        If $iWheel = 2 And $Random = 4 Then
            $iRandom = 5
        Else
            $iRandom = $Random
        EndIf
        GUICtrlSetImage($Wheel[$iWheel] , $iRandom & ".jpg")
        $iWheel += 1
    Until $iWheel = 4
EndFunc

The reason why if it is on wheel 2 and random 4 it returns a 5 because 5 is a wild and a wild can only be found in the center of the slot machine.

This code seems to work for me.

If this helps explain it any better

Min Bid = 1 
Max Bid = 3 
Payout = 2 * Bid = 2,4,6

Pay out 1 Bid = 2
Pay out 2 Bid = 4
Pay out 3 Bid = 6

Final Payout Table:

(1) (1) (1) = 2 * Bid
(2) (2) (2) = 3 * Bid
(3) (3) (3) = 4 * Bid
(4) (5) (4) = 5 * Bid

(1) (5) (1) = 2 * Bid
(2) (5) (2) = 3 * Bid
(3) (5) (3) = 4 * Bid
(4) (5) (4) = 5 * Bid
Edited by SkellySoul
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...