
-----------------------------------

Fri Jan 16, 2004 10:03 am

Slot Machine Graphics
-----------------------------------
This is my slot machine.

%-- Slot Machine Game
%-- Varibles / Constant / Setscreens / Randoms / Drawfill

var id := Window.Open ("fullscreen,nocursor")
randomize
drawfill (1, 1, black, black)
const height := 300
const width := height * 3 div 2
const framex := (maxx - width) div 2
const framey := (maxy - height) div 2
const gap := width div 16
const window_width := width div 16 * 4
var startx : int
var starty : int
var s1, s2, s3 : int
var handle := framey + height
var handle_size := 20
var enter : string
var money_count : int := 10
var bet, x, y, z : int
var coin_count : int := money_count
const coin_width := (width div 8)
const coin_height := (height div 64)
var font1 := Font.New ("Palatino:25:bold")
var music : int

%-- Music Procedures

proc open1

    play ("2E2G2A 4p 2E2G4A+2A 4p 2E2G2A 4p 2G1E")

end open1

proc open2

    play (">4C4C 2p 4E4F 4C4C 2p 4C4C 2p 4E4F 4C4C 2p  1C")

end open2

proc open3

    play ("2D2D2D2D 2E2E2E2E 2C2C2C2C 4D4D4D4D 8D8D8D8D 8D8D8D8D")

end open3

proc open4

    play ("4D8D8D4D4E 4D8D8D4D4E 2D2C2D 4p 4D8D8D4D4E 4D8D8D4D4E 2D2C4F 1P >6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p 6A 6p")

end winning_music

%-- Flashing Lights

proc win

    for i : 1 .. 20
        drawfilloval (framex + (width div 2), framey + (height div 4), 10,
            10, 12)
        drawfilloval (framex + (width div 3), framey + (height div 4), 10,
            10, 14)
        drawfilloval (framex + (width div 3 * 2), framey + (height div 4),
            10, 10, 14)
        delay (100)
        drawfilloval (framex + (width div 2), framey + (height div 4), 10,
            10, 14)
        drawfilloval (framex + (width div 3), framey + (height div 4), 10,
            10, 12)
        drawfilloval (framex + (width div 3 * 2), framey + (height div 4),
            10, 10, 12)
        delay (100)
    end for
    drawfilloval (framex + (width div 2), framey + (height div 4), 10, 10, 8)
    drawfilloval (framex + (width div 3), framey + (height div 4), 10, 10, 8)
    drawfilloval (framex + (width div 3 * 2), framey + (height div 4), 10,
        10, 8)

end win

%-- Draw 5 Objects

proc object_1

    drawfilloval (startx, starty, 20, 20, 10)

end object_1

proc object_2

    drawline (startx - (width div 16), starty - (height div 16), startx
        + (width div 16), starty + (height div 16), 14)
    drawline (startx + (width div 16), starty - (height div 16), startx
        - (width div 16), starty + (height div 16), 14)

end object_2

proc object_3

    drawfillstar (startx - (width div 12), starty - (height div 10), startx
        + (width div 12), starty + (height div 10), 2)

end object_3

proc object_4

    drawfillbox (startx - (width div 32), starty - (height div 10), startx
        + (width div 32), starty + (height div 10), 9)
    drawfillbox (startx - (width div 12), starty - (height div 32), startx
        + (width div 12), starty + (height div 32), 9)

end object_4

proc object_5

    drawfillmapleleaf (startx - (width div 12), starty - (height div 10),
        startx + (width div 12), starty + (height div 10), 12)

end object_5

%-- Main Program

colorback (7)
Text.Color (14)

locate (50, 16)
put "MONEY : ", money_count

locate (55, 58)
put "Press Enter To Play" ..
get enter : *
locate (55, 58)
put "" : 20

loop

    %-- Money Count Under Money Plate

    locate (50, 16)
    put "MONEY : ", money_count

    %-- Get Bet

    loop

        locate (55, 47)
        put "How Much Of Your $", money_count, " Would You Like To Bet? :  "
            ..
        get bet
        exit when bet > 0 and bet < money_count + 1
        locate (55, 94)
        put "" : 10
    end loop
    locate (55, 47)
    put "" : 50
    locate (55, 55)
    put "Press Enter To Start"
    get enter : *
    locate (55, 55)
    put "" : 50

    %-- Moving Handle

    drawfillbox (framex + width + (gap div 6 * 5), framey + (height div 2),
        framex + width + (gap * 6 div 5), framey + height, 8)
    drawfillbox (framex + width, framey + (height div 2), framex + width
        + (gap div 10 * 17), framey + (height div 32 * 15), 8)
    for i : 1 .. (height div 4)
        drawfilloval (framex + width + gap, handle, handle_size,
            handle_size, 14)
        delay (10)
        drawfilloval (framex + width + gap, handle, handle_size,
            handle_size, black)
        handle := handle - 2
        handle_size := handle_size
    end for
    handle := framey + height
    drawfillbox (framex + width + (gap div 6 * 5), framey + (height div 2),
        framex + width + (gap * 6 div 5), framey + height, 8)
    drawfillbox (framex + width, framey + (height div 2), framex + width
        + (gap div 10 * 17), framey + (height div 32 * 15), 8)
    drawfilloval (framex + width + gap, handle, handle_size, handle_size, 14)

    %-- Slots

    for roll1 : 1 .. 30
        randint (s1, 1, 5)
        startx := framex + (width div 16 * 3)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s1 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        randint (s2, 1, 5)
        startx := framex + (width div 16 * 8)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s2 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        randint (s3, 1, 5)
        startx := framex + (width div 16 * 13)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s3 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        delay (100)
    end for

    for roll1 : 1 .. 30
        randint (s1, 1, 5)
        startx := framex + (width div 16 * 3)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s1 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        randint (s2, 1, 5)
        startx := framex + (width div 16 * 8)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s2 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        delay (100)
    end for

    for roll1 : 1 .. 30
        randint (s1, 1, 5)
        startx := framex + (width div 16 * 3)
        drawfillbox (startx - (width div 12), starty - (height div 10),
            startx + (width div 12), starty + (height div 10), black)
        case s1 of
            label 1 :
                object_1
            label 2 :
                object_2
            label 3 :
                object_3
            label 4 :
                object_4
            label 5 :
                object_5
        end case
        delay (100)
    end for

    %-- Winnings

    if s1 = s2 and s2 = s3 and s3 = 1 then
        money_count := money_count + bet
        fork winning_music
        win
    elsif s1 = s2 and s2 = s3 and s3 = 2 then
        money_count := money_count + bet
        fork winning_music
        win
    elsif s1 = s2 and s2 = s3 and s3 = 3 then
        money_count := money_count + (bet * 2)
        fork winning_music
        win
    elsif s1 = s2 and s2 = s3 and s3 = 3 then
        money_count := money_count + (bet * 2)
        fork winning_music
        win
    elsif s1 = s2 and s2 = s3 and s3 = 5 then
        money_count := money_count + (bet * 3)
        fork winning_music
        win
    elsif s1 = s2 and s1 = 1 or s2 = s3 and s2 = 1 or s3 = s1 and s3 = 1 then
        money_count := money_count + 1
        fork winning_music
        win
    elsif s1 = s2 and s1 = 2 or s2 = s3 and s2 = 2 or s3 = s1 and s3 = 2 then
        money_count := money_count + 2
        fork winning_music
        win
    elsif s1 = s2 and s1 = 3 or s2 = s3 and s2 = 3 or s3 = s1 and s3 = 3 then
        money_count := money_count + 3
        fork winning_music
        win
    elsif s1 = s2 and s1 = 4 or s2 = s3 and s2 = 4 or s3 = s1 and s3 = 4 then
        money_count := money_count + 4
        fork winning_music
        win
    elsif s1 = s2 and s1 = 5 or s2 = s3 and s2 = 5 or s3 = s1 and s3 = 5 then
        money_count := money_count + 5
        fork winning_music
        win
    else
        money_count := money_count - bet
    end if

    %-- White Lights

    drawfilloval (framex + (width div 2), framey + (height div 4), 10, 10, 0)
    drawfilloval (framex + (width div 3), framey + (height div 4), 10, 10, 0)
    drawfilloval (framex + (width div 3 * 2), framey + (height div 4), 10,
        10, 0)
    drawfilloval (framex + (width div 2), framey + (height div 4), 10, 10, 0)
    drawfilloval (framex + (width div 3), framey + (height div 4), 10, 10, 0)
    drawfilloval (framex + (width div 3 * 2), framey + (height div 4), 10,
        10, 0)

    %-- Re-Draw Money Pile

    if money_count < 50 then
        drawfillbox (framex - (coin_width div 4 * 5), framey + (coin_height
            * 1), framex - (coin_width div 8 * 9) + coin_width, framey
            + (coin_height) + (height - coin_height), black)
        coin_count := money_count
        for i : 1 .. coin_count
            drawfillbox (framex - (coin_width div 4 * 5), framey
                + (coin_height * i), framex - (coin_width div 8 * 9) +
                coin_width, framey + (coin_height * i + 1), 14)
        end for
    end if
    locate (50, 16)
    put "" : 30
    locate (50, 16)
    put "MONEY : ", money_count

    %-- Exit Statment 1

    exit when money_count = 0

    %-- Play Again

    locate (55, 45)
    put "Would You Like To Play Again? (y/n) : " ..
    loop
        locate (55, 85)
        get enter : *
        exit when enter = "y" or enter = "n"
        locate (55, 85)
        put "" : 10
    end loop
    locate (55, 45)
    put "" : 50

    %-- Exit Statment 2

    exit when enter = "n"

end loop

%-- Final Statments

if money_count = 10 then
    locate (55, 58)
    put "YOU BROKE EVEN!"
elsif money_count > 10 then
    locate (55, 55)
    put "YOU CAME OUT ", money_count - 10, " DOLLARS ON TOP"
elsif money_count = 0 then
    locate (55, 55)
    put "YOU LOST EVERYTHING"
elsif money_count < 10 then
    locate (55, 55)
    put "YOU LOST ", 10 - money_count, " DOLLARS OVER ALL"
end if

play (">4C4C4E8F4C 2p 4C4C4E8F4C 2p 4C4C4E8F 4C4C4E4F 4C4C4E8F4C")


