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

Username:   Password: 
 RegisterRegister   
 I need help with a roulette game, I dont know how to make the roulette stop. Been trying for hours...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JBishop




PostPosted: Sat Jun 18, 2016 11:13 pm   Post subject: I need help with a roulette game, I dont know how to make the roulette stop. Been trying for hours...

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
In my game you bet on a certain colour, but the colour won't stop changing even though it should be.


Describe what you have tried to solve this problem
I have made various variables to try and fix this problem, with none that seemed to help.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var coins, bet : int
var win, lose : boolean
var mx, my, button : int
var didbet, spin, spinstop : boolean := false
var c : string := ""
var r1, colortemp, randstop : int
var font1 : int
var clr : array 1 .. 5 of int
var pickblue, pickred, pickyellow : boolean := false
var boxx1, boxx2, boxx3, boxx4, boxx5 : int
var num : int
var stop : int := 0
coins := 20
bet := 0
font1 := Font.New ("Agency FB:20")

boxx1 := 80
boxx2 := 194
boxx3 := 306
boxx4 := 418
boxx5 := 530

for i : 1 .. 5
    clr (i) := 175
end for






procedure spinit

   
   
        for i : 1 .. 20
            randint (r1, 1, 3)
           
            if r1 = 1 then
                colortemp := 9     %12, 14
            elsif r1 = 2 then
                colortemp := 12
            else
                colortemp := 14
            end if

           



           

            Draw.FillBox (boxx1, 315, 642, 313 + 108, colortemp)
         
            delay (10)
        end for

       

   


end spinit




procedure bet1
    coins -= 1
    bet += 1
end bet1
procedure bet5
    coins -= 5
    bet += 5
end bet5
procedure bet10
    coins -= 10
    bet += 10
end bet10
procedure bet25
    coins -= 25
    bet += 25
end bet25



procedure game
   
    View.Set ("graphics:720;480,offscreenonly, nobuttonbar")
    Draw.FillBox (0, 0, maxx, maxy, green)
    Draw.FillBox (80, 440, 642, 300, black)
    Draw.FillBox (10, 10, 170, 100, white)
    Font.Draw ("1", 90, 45, font1, black)
    Draw.FillBox (190, 10, 350, 100, white)
    Font.Draw ("5", 270, 45, font1, black)
    Draw.FillBox (370, 10, 530, 100, white)
    Font.Draw ("10", 440, 45, font1, black)
    Draw.FillBox (550, 10, 710, 100, white)
    Font.Draw ("25", 620, 45, font1, black)

    Draw.FillBox (boxx1, 315, boxx1 + 112, 313 + 108, clr (1))
    Draw.FillBox (boxx2, 315, boxx2 + 112, 313 + 108, clr (2))
    Draw.FillBox (boxx3, 315, boxx3 + 112, 313 + 108, clr (3))
    Draw.FillBox (boxx4, 315, boxx4 + 112, 313 + 108, clr (4))
    Draw.FillBox (boxx5, 315, boxx5 + 112, 313 + 108, clr (5))

    Draw.FillOval (180, 200, 50, 50, blue)
    Draw.FillOval (360, 200, 50, 50, yellow)
    Draw.FillOval (540, 200, 50, 50, red)

    Mouse.Where (mx, my, button)

    if mx > 145 and mx < 215 and my > 180 and my < 255 and button = 1 then
        if c ~= "red" and c ~= "yellow" then
            c := "blue"
        end if
    end if
    if my > 180 and my < 250 and mx > 320 and mx < 395 and button = 1 then
        if c ~= "red" and c ~= "blue" then
            c := "yellow"
        end if
    end if
    if my > 180 and my < 250 and mx > 505 and mx < 575 and button = 1 then
        if c ~= "blue" and c ~= "yellow" then
            c := "red"
        end if
    end if


    if c = "blue" then
        if my > 180 and my < 250 and mx > 320 and mx < 395 and button = 1 then
            c := "blue"
        elsif my > 180 and my < 250 and mx > 505 and mx < 575 and button = 1 then
            c := "blue"
        end if
    end if


    if mx > 10 and mx < 170 and my > 10 and my < 100 and button = 1 then
        if coins >= 1 then
            didbet := true
            bet1
        else
            lose := true
        end if
    end if

    if mx > 190 and mx < 350 and my > 10 and my < 100 and button = 1 then
        if coins >= 5 then
            didbet := true
            bet5
        else
            lose := true
        end if
    end if

    if mx > 370 and mx < 530 and my > 10 and my < 100 and button = 1 then
        if coins >= 10 then
            didbet := true
            bet10
        else
            lose := true
        end if
    end if

    if mx > 550 and mx < 710 and my > 10 and my < 100 and button = 1 then
        if coins >= 25 then
            didbet := true
            bet25
        else
            lose := true
        end if
    end if



    if c = "blue" and bet > 0 then
        spinit
        spin := true
    elsif
            c = "red" and bet > 0 then
        spinit
        spin := true
    elsif c = "yellow" and bet > 0 then
        spinit
        spin := true
    else
        spin := false

    end if

    Font.Draw (intstr (bet), 10, 350, font1, white)
    Font.Draw (intstr (coins), 10, 320, font1, white)
    Font.Draw (c, 10, 290, font1, white)

    View.Update
    delay (200)
end game

loop
    game
end loop




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: