Slot Machine

This forum is for posting code that needs help.

CAMERIZZLE
Posts: 1
Joined: Tue Apr 29, 2008 9:03 pm

Slot Machine

Post by CAMERIZZLE »

Attached Zip contains all of the files necessary to run, including images.

EDIT: THIS IS THE UPDATED, WORKING CODE, FOR ANYONE THAT CARES!!! ATTACHMENT IS UPDATED AS WELL, DOWNLOAD AND LET ME KNOW WHAT YOU THINK!!!!

Code: Select all

nomainwin

    cashset = 100
    bankset = 100
    bet1 = 5
    bet2 = 10
    bet3 = 15


    [newgame]
    WindowWidth = 160
    WindowHeight = 220
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)
    statictext #selections.statictext2, "Cash In Hand:", 14, 16, 88, 20
    textbox #selections.CIH, 102, 6, 40, 25
    statictext #selections.statictext4, "Cash In Bank:", 14, 46, 88, 20
    textbox #selections.CIB, 102, 36, 40, 25
    statictext #selections.statictext7, "Bet 1:", 62, 76, 35, 20
    textbox #selections.bet1, 102, 66, 40, 25
    statictext #selections.statictext9, "Bet 2:", 62, 106, 40, 20
    textbox #selections.bet2, 102, 96, 40, 25
    statictext #selections.statictext11, "Bet 3:", 62, 136, 35, 20
    textbox #selections.bet3, 102, 126, 40, 25
    button #selections.button13, "Submit", [subsel], UL, 46, 161, 58, 25
    open "Selections" for window_nf as #selections
    print #selections, "font ms_sans_serif 0 16"
    print #selections.CIH, cashset
    print #selections.CIB, bankset
    print #selections.bet1,bet1
    print #selections.bet2,bet2
    print #selections.bet3,bet3
    print #selections, "trapclose [close2]"
    print #selections.button13, "!setfocus"
    wait

[subsel]
print #selections.CIH, "!contents? cashset"
print #selections.CIB, "!contents? bankset"
print #selections.bet1,"!contents? bet1"
print #selections.bet2, "!contents? bet2"
print #selections.bet3, "!contents? bet3"
if cashset < bet1 then wait
if bankset <= 0 then wait
if bet1 = 0 then wait
if bet2 = 0 then wait
if bet3 = 0 then wait
close #selections
cash = cashset
bank = bankset


    bet = 0
    pic1$ = "Sword"
    pic2$ = "Axe"
    pic3$ = "Hammer"

    loadbmp "Logo","Slotsname.bmp"
    loadbmp "Sword","Sword.bmp"
    loadbmp "Axe","Axe.bmp"
    loadbmp "Hammer","Hammer.bmp"
    loadbmp "Amethyst","Amethyst.bmp"

    WindowWidth = 340
    WindowHeight = 455
    UpperLeftX=int((DisplayWidth-WindowWidth)/2 + 1)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)
    graphicbox #main.pic3, 230, 125,  64,  64
    graphicbox #main.pic2, 130, 125,  64,  64
    graphicbox #main.pic1,  30, 125,  64,  64
    graphicbox #main.logobox,  55,   7, 216,  47
    textbox #main.cash, 245, 242,  65,  25
    textbox #main.bank,  10, 242,  65,  25
    button #main.1bet,"$" + Str$(bet1),[1bet], UL, 90, 242,  35,  25
    button #main.2bet,"$" + Str$(bet2),[2bet], UL, 140, 242,  35,  25
    button #main.3bet,"$" + Str$(bet3),[3bet], UL, 190, 242,  35,  25
    button #main.button38,"SPIN!!!!!",[Spin], UL, 105,  65, 115,  50
    textbox #main.payoutbox,  70, 195, 185,  25
    groupbox #main.groupbox, "Payout:",   5, 277, 320, 140
    statictext #main.statictext3, "Amethyst x3",  10, 293,  71,  17
    statictext #main.statictext4, "Amethyst x2",  10, 307,  71,  20
    statictext #main.statictext5, "Sword x3",  10, 322,  54,  20
    statictext #main.statictext6, "Sword x2",  10, 337,  54,  20
    statictext #main.statictext7, "Axe x2",  10, 367,  39,  20
    statictext #main.statictext8, "Axe x3",  10, 352,  39,  17
    statictext #main.statictext9, "Hammer x3",  10, 382,  68,  20
    statictext #main.statictext10, "Hammer x2",  10, 397,  68,  15
    statictext #main.statictext12, "Bet x10", 275, 292,  43,  20
    statictext #main.statictext13, "Bet x5", 280, 307,  36,  20
    statictext #main.statictext14, "Bet x3", 280, 322,  36,  20
    statictext #main.statictext15, "  Bet x2", 275, 337,  46,  20
    statictext #main.statictext16, "  Bet x2", 275, 352,  46,  20
    statictext #main.statictext17, "  Bet x1", 275, 367,  46,  20
    statictext #main.statictext18, " Bet x1", 280, 382,  40,  20
    statictext #main.statictext19, "Bet x.5", 280, 397,  39,  15
    statictext #main.statictext11, "..............................................................",  85, 292, 185,  20
    statictext #main.statictext20, ".....................................................................",  85, 307, 196,  20
    statictext #main.statictext21, ".....................................................................",  70, 322, 208,  20
    statictext #main.statictext22, ".........................................................................",  65, 337, 214,  20
    statictext #main.statictext23, "...............................................................................",  55, 352, 224,  20
    statictext #main.statictext24, "...............................................................................",  55, 366, 222,  18
    statictext #main.statictext25, "..................................................................",  80, 382, 200,  20
    statictext #main.statictext26, ".................................................................",  80, 397, 195,  15
    statictext #main.statictext31, "Cash:", 260, 222,  34,  20
    statictext #main.statictext33, "Bank:",  25, 222,  34,  20
    statictext #main.statictext34, "Bet:", 150, 222,  23,  20
    open "World Of Warcraft Slots" for window_nf as #main
    print #main, "font ms_sans_serif 10"
    print #main.pic1, "down"
    print #main.pic1, "drawbmp Sword 0 0"
    print #main.pic1, "flush"
    print #main.pic2, "drawbmp Axe 0 0 "
    print #main.pic2, "flush"
    print #main.pic3, "drawbmp Hammer 0 0"
    print #main.pic3, "flush"
    print #main.logobox, "drawbmp Logo 0 0"
    print #main.logobox, "flush"
    print #main.cash, "     $"+ str$(cash)
    print #main.bank, "     $" +str$(bank)
    print #main, "trapclose [close]"
    print #main.cash, "!disable"
    print #main.bank, "!disable"
    print #main.2bet, "!setfocus"
    print #main.payoutbox, "!disable"
    print #main.payoutbox, "     pick a bet and press spin!"
     if cash < bet2 then print #main.2bet, "!disable"
    if cash < bet3 then print #main.3bet, "!disable"
    bet = bet2
    print #main.2bet, "!font ms_sans_serif 10 bold"
    wait
    close #main




[1bet]
    bet = bet1
    print #main.button38, "!setfocus"
    print #main.1bet,"!font ms_sans_serif 10 bold"
    print #main.2bet,"!font ms_sans_serif 10"
    print #main.3bet,"!font ms_sans_serif 10"
wait
    wait

[2bet]
    print #main.button38, "!setfocus"
    bet = bet2
        print #main.1bet,"!font ms_sans_serif 10 "
    print #main.2bet,"!font ms_sans_serif 10 bold"
    print #main.3bet,"!font ms_sans_serif 10"
    wait

[3bet]
    print #main.button38, "!setfocus"
    bet = bet3
    print #main.1bet,"!font ms_sans_serif 10 "
    print #main.2bet,"!font ms_sans_serif 10 "
    print #main.3bet,"!font ms_sans_serif 10 bold"
    wait

[Spin]
if bet = 0 then wait
print #main.payoutbox, ""
print #main.pic1, "cls"
print #main.pic2, "cls"
print #main.pic3, "cls"
print #main.button38, "!disable"
print #main.1bet, "!disable"
print #main.2bet, "!disable"
print #main.3bet, "!disable"
amethyst = 0
sword = 0
axe = 0
hammer = 0
cash = cash - bet
print #main.cash, "     $" + str$(cash)
bank = bank + bet
print #main.bank, "     $" + str$(bank)

for x = 1 to 30
print #main.logobox, "drawbmp Logo 0 0"
    rnd1 = int(rnd(1)*100)
    Select Case
        case rnd1 <15
            print #main.pic1, "drawbmp Amethyst 0 0"
            slot1 = 4
            if x = 30 then
                amethyst = amethyst + 1
                print #main.pic1, "flush"
            else
                print #main.pic1, "discard"
            end if

        case (rnd1 >=15) and (rnd1 < 50)
            print #main.pic1, "drawbmp Sword 0 0"
            slot1 = 3
            if x = 30 then
                sword = sword + 1
               print #main.pic1, "flush"
            else
                print #main.pic1, "discard"
            end if

        case (rnd1 >=50) and (rnd1 < 75)
            print #main.pic1, "drawbmp Axe 0 0"
            slot1 = 1
           if x = 30 then
                axe = axe + 1
                print #main.pic1, "flush"
            else
                print #main.pic1, "discard"
            end if

        case rnd1 >= 75
            print #main.pic1, "drawbmp Hammer 0 0"
            slot1 = 1
            if x = 30 then
                hammer = hammer + 1
                print #main.pic1, "flush"
            else
                print #main.pic1, "discard"
            end if
    End Select

    rnd2 = int(rnd(1)*100)
    Select Case
        case rnd2 <10
            print #main.pic2, "drawbmp Amethyst 0 0"
            slot2 = 4
            if x = 30 then
                amethyst = amethyst + 1
                print #main.pic2, "flush"
            else
                print #main.pic2, "discard"
            end if

        case (rnd2 >=10) and (rnd2 < 40)
            print #main.pic2, "drawbmp Sword 0 0"
            slot2 = 3
            if x = 30 then
                sword = sword + 1

                print #main.pic2, "flush"
            else
                print #main.pic2, "discard"
            end if

        case (rnd2 >=40) and (rnd2 < 80)
            print #main.pic2, "drawbmp Axe 0 0"
            slot2 = 2
            if x = 30 then
                axe = axe + 1
                print #main.pic2, "flush"
            else
                print #main.pic2, "discard"
            end if

        case rnd2 >= 80
            print #main.pic2, "drawbmp Hammer 0 0"
            slot2 = 1
            if x = 30 then
                hammer = hammer + 1
                print #main.pic2, "flush"
            else
                print #main.pic2, "discard"
            end if
    End Select
    rnd3 = int(rnd(1)*100)
    Select Case
        case rnd3 <10
            print #main.pic3, "drawbmp Amethyst 0 0"
            slot3 = 4
            if x = 30 then
                amethyst = amethyst + 1
                print #main.pic3, "flush"
            else
                print #main.pic3, "discard"
            end if

        case (rnd3 >=10) and (rnd3 < 25)
            print #main.pic3, "drawbmp Sword 0 0"
            slot2 = 3
            if x = 30 then
                sword = sword + 1
                pic3$ = "Sword"
                print #main.pic3, "flush"
            else
                print #main.pic3, "discard"
            end if

        case (rnd3 >=25) and (rnd3 < 55)
            print #main.pic3, "drawbmp Axe 0 0"
            slot3 = 2
            if x = 30 then
                axe = axe + 1
                pic3$ = "Axe"
                print #main.pic3, "flush"
            else
                print #main.pic3, "discard"
            end if

        case rnd3 >= 55
            print #main.pic3, "drawbmp Hammer 0 0"
            slot3 = 1
            if x = 30 then
                hammer = hammer + 1
                pic3$ = "Hammer"
                print #main.pic3, "flush"
            else
                print #main.pic3, "discard"
            end if
    End Select
    call Pause 1
next x

gosub [scoring]



if cash < bet1 then print #main.1bet, "!disable"
if cash < bet2 then print #main.2bet, "!disable"
if cash < bet3 then print #main.3bet, "!disable"
if cash >= bet1 then print #main.1bet, "!enable"
if cash >= bet2 then print #main.2bet, "!enable"
if cash >= bet3 then print #main.3bet, "!enable"
if cash < bet1 then
        print #main.1bet, "!font ms_sans_serif 10"
        bet = 0
end if

if cash < bet2 then
        print #main.2bet, "!font ms_sans_serif 10"
        bet = 0
end if

if cash < bet3 then
        print #main.3bet, "!font ms_sans_serif 10"
        bet = 0
end if

if cash < bet1 then [lose]
if bank <= 0 then [win]


'for debugging purposes
'cls
'print  "a:";amethyst
'print "s:";sword
'print "axe:";axe
'print "h";hammer

wait
close #main



[lose]
    notice "I'm sorry, you dont have enough money to make a bet"
    confirm "Play Again?";q$
    if q$ = "yes" then
        close #main
        goto[newgame]
    end if
    notice "Thank you for playing!"
    close #main
    end

[win]
    notice "congratulations, you broke the bank!"
    confirm "Play Again?";q$
    if q$ = "yes" then
        close #main
        goto[newgame]
    end if
    notice "Thank you for playing!"
    close #main
    end

[close]
    confirm "are you sure?";q$
    if q$ = "yes" then
        notice "Thank you for playing!"
        close #main
        end
    end if
  wait



[close2]
    confirm "are you sure?";q$
    if q$ = "yes" then
        close #selections
        end
    end if
 wait



[scoring]

    if amethyst = 3 then mult = 10
    if amethyst = 2 then mult = 5
    if sword = 3 then mult = 3
    if sword = 2 then mult = 2
    if axe = 3 then mult = 2
    if axe = 2 then mult = 1
    if hammer = 3 then mult = 1
    if hammer = 2 then mult = .5

    if amethyst <=1 and sword <=1 and axe <=1 and hammer <=1 then
        mult = 0
    end if

    cash = cash + mult * bet
    bank = bank - mult * bet
    if bank < 0 then
        cash = cash + bank
        bank = 0
    end if

    call Pause 500

    if amethyst = 3 then notice "JACKPOT!!!!!!!"
    s$ = "This round, you made: $" + str$(mult * bet)
    print #main.cash, "     $"+str$(cash)
    print #main.bank, "     $"+str$(bank)

print #main.payoutbox, "cls"
print #main.payoutbox, s$
print #main.button38, "!enable"
print #main.1bet, "!enable"
print #main.2bet, "!enable"
print #main.3bet, "!enable"
print #main.button38, "!setfocus"


return

sub Pause mil
    t=time$("milliseconds")
    while time$("milliseconds")<t+mil
    wend
end sub


You do not have the required permissions to view the files attached to this post.