Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Slot Machine Graphics
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Peckerhead Productions




PostPosted: Fri Jan 16, 2004 10:03 am   Post subject: Slot Machine Graphics

This is my slot machine.

code:
%-- 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 <4B-4B >4C4C 2p 4E4F 4C4C 2p <4B-4B > 1C")

end open2

proc open3

    play ("2D2D2D2D 2E2E2E2E 2C2C2C2C 4D4D4D4D 8D8D8D8D 8D8D8D8D")

end open3

proc open4

    play ("4D8D8D4D4E 4D8D8D4D4E 2D2C2D 4p 4D8D8D4D4E 4D8D8D4D4E 2D2C<1A")

end open4

proc open5

    play ("1D3D3F4D3D 1P 1G3D3F>4F 1P <1C3F3G3G4G 1P 1D")

end open5

%-- Entery Screen + Music

randint (music, 1, 5)

colorback (8)
Font.Draw ("WELCOME TO WALDO'S SLOTS", framex + (width div 32), framey
    + (height div 3), font1, 12)
Font.Free (font1)

case music of
    label 1 :
        open1
    label 2 :
        open2
    label 3 :
        open3
    label 4 :
        open4
    label 5 :
        open5
end case

drawfill (1, 1, 7, 7)

font1 := Font.New ("Palatino:16:bold")

%-- Main Window Design
%-- Main Machine

drawbox (framex, framey, framex + width, framey + height, 0)
for i : 1 .. 3
    drawbox (framex + (gap * i) + (window_width * (i - 1)),
        framey + (height div 2),
        framex + (gap * i) + (window_width * i),
        framey + (height div 8 * 7),
        0)
end for

%-- Outline Of Slot Boxxes

drawbox (framex + (gap div 2), framey + (height div 2) - (gap div 2), framex
    + gap + window_width + (gap div 2), framey + (height div 16 * 15), 0)
drawbox (framex + (gap div 2) + window_width + gap, framey + (height div 2)
    - (gap div 2), framex + (gap div 2) + (window_width * 2) + (gap * 2),
    framey + (height div 16 * 15), 0)
drawbox (framex + (gap div 2) + (window_width * 2) + (gap * 2), framey
    + (height div 2) - (gap div 2), framex + (gap div 2) + (window_width *
    3) + (gap * 3), framey + (height div 16 * 15), 0)
drawfill (framex + gap, framey + gap, 8, 0)
drawfill (framex + (gap div 3 * 2), framey + (height div 2 + (gap div 3 *
    2)), 12, 0)
drawfill (framex + (gap div 3 * 6) + window_width, framey + (height div 2
    + (gap div 3 * 2)), 14, 0)
drawfill (framex + (gap div 3 * 9) + (window_width * 2), framey + (height
    div 2 + (gap div 3 * 2)), 12, 0)

%-- 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)
drawfilloval (framex + width + gap, handle, handle_size, handle_size, 14)

%-- Opening Mapleleafs for slots

startx := framex + (width div 16 * 3)
starty := framey + (height div 32 * 23)
drawfillmapleleaf (startx - (width div 12), starty - (height div 10), startx
    + (width div 12), starty + (height div 10), 12)
startx := framex + (width div 16 * 8)
drawfillmapleleaf (startx - (width div 12), starty - (height div 10), startx
    + (width div 12), starty + (height div 10), 12)
startx := framex + (width div 16 * 13)
drawfillmapleleaf (startx - (width div 12), starty - (height div 10), startx
    + (width div 12), starty + (height div 10), 12)

%-- 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)

%-- Money
%-- Money Holding Plate

drawfillbox (framex - (width div 6), framey, framex, framey + (height div
    64), 8)

%-- Money

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

%-- Legend

colorback (7)
Text.Color (10)
locate (1, 1)
put "2 Green Circles : $1"
locate (2, 1)
put "3 Green Circles : Bet"
Text.Color (14)
locate (3, 1)
put "2 Yellow Xs : $2"

locate (1, 56)
put "3 Yellow Xs : Bet"
Text.Color (2)
locate (2, 56)
put "2 Green Stars : $3"
locate (3, 56)
put "3 Green Stars : Bet * 2"
Text.Color (9)
locate (4, 56)
put "2 Blue Crosses : $4"

locate (1, 106)
put "3 Blue Crosses : Bet * 2"
Text.Color (12)
locate (2, 106)
put "2 Mapleleafs : $5"
locate (3, 106)
put "3 Mapleleafs : Bet * 3"

%-- Slot Machine Title

colorback (8)
Font.Draw ("WALDO'S SLOTS", framex + (width div 32 * 11), framey + (height
    div 3), font1, 12)
Font.Free (font1)

%-- Procedures
%-- Winning Music

process winning_music

    play (">>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")

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: