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

Username:   Password: 
 RegisterRegister   
 Snake and Ladder in turing !!! HELP PLZ !!!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TonyTran




PostPosted: Thu Dec 10, 2009 8:39 pm   Post subject: Snake and Ladder in turing !!! HELP PLZ !!!!!

[size=14]I'm making a game in turing snakes and ladders. I want to make the players go zic-zac from 1 to 100, but it doesn't work. Can u help me plz .


Turing:


<%tony

setscreen ("graphics:1000,700;nobuttonbar")

var x, y, x1, y1 : int := 0
var font : int




font := Font.New ("serif:14")

proc board

    var num : string
    var counter, counter1, counter2, counter3, counter4, counter5, counter6, counter7, counter8, counter9 : int := 0


    drawfillbox (0, 0, maxx, maxy, 43)
    loop
        drawline (x, y, x, 700, 1)
        drawline (x1, y1, 700, y1, 1)
        x := x + 70
        y1 := y1 + 70
        exit when x > 700
    end loop

    drawfillbox (810, 540, 850, 580, 0)
    drawfillbox (870, 540, 910, 580, 0)
    drawfilloval (750, 400, 20, 20, 48)
    drawfilloval (800, 400, 20, 20, 53)
    drawfilloval (30, 20, 10, 10, 48)
    drawfilloval (40, 50, 10, 10, 53)
    for i : 1 .. 10
        num := intstr (i)
        Draw.Text (num, 2 + counter, 55, font, black)
        counter := counter + 70
    end for

    for k : 11 .. 20
        num := intstr (k)
        Draw.Text (num, 630 + counter1, 125, font, black)
        counter1 := counter1 - 70
    end for

    for l : 21 .. 30
        num := intstr (l)
        Draw.Text (num, 2 + counter2, 195, font, black)
        counter2 := counter2 + 70
    end for

    for n : 31 .. 40
        num := intstr (n)
        Draw.Text (num, 630 + counter3, 265, font, black)
        counter3 := counter3 - 70
    end for

    for n : 41 .. 50
        num := intstr (n)
        Draw.Text (num, 2 + counter4, 335, font, black)
        counter4 := counter4 + 70
    end for

    for n : 51 .. 60
        num := intstr (n)
        Draw.Text (num, 630 + counter5, 405, font, black)
        counter5 := counter5 - 70
    end for

    for n : 61 .. 70
        num := intstr (n)
        Draw.Text (num, 2 + counter6, 475, font, black)
        counter6 := counter6 + 70
    end for

    for n : 71 .. 80
        num := intstr (n)
        Draw.Text (num, 630 + counter7, 545, font, black)
        counter7 := counter7 - 70
    end for

    for n : 81 .. 90
        num := intstr (n)
        Draw.Text (num, 2 + counter8, 615, font, black)
        counter8 := counter8 + 70
    end for

    for n : 91 .. 100
        num := intstr (n)
        Draw.Text (num, 630 + counter9, 685, font, black)
        counter9 := counter9 - 70
    end for

end board


proc dice

    var x3, y3, buttonnumber, buttonupdown : int
    var d1, d2, dt : int
    var x4, x5, y4, y5 : int
    var move : int := 0
    var turn : int := 1
    var bl, bn, bn1 : int := 0
    var odt : int := 0
    var x4_1, y4_1 : int
    x4_1 := 30
    y4_1 := 20

    y4 := 20

    y5 := 50

    drawfillbox (790, 590, 940, 620, 8)
    for g : 1 .. 3
        drawbox (790 - g, 590 - g, 940 + g, 620 + g, 31)
    end for
    Draw.Text ("Click to roll dice", 800, 600, font, red)
    loop
        buttonwait ("down", x3, y3, buttonnumber, buttonupdown)
        if x3 < 940 and x3 > 790 then
            if y3 < 620 and y3 > 590 then
                randint (d1, 1, 6)
                randint (d2, 1, 6)
                if d1 = 1 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (830, 560, 3, 3, 40)
                elsif d1 = 2 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (830, 570, 3, 3, 40)
                    drawfilloval (830, 550, 3, 3, 40)
                elsif d1 = 3 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (830, 560, 3, 3, 40)
                    drawfilloval (830, 570, 3, 3, 40)
                    drawfilloval (830, 550, 3, 3, 40)
                elsif d1 = 4 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (820, 550, 3, 3, 40)
                    drawfilloval (840, 550, 3, 3, 40)
                    drawfilloval (820, 570, 3, 3, 40)
                    drawfilloval (840, 570, 3, 3, 40)
                elsif d1 = 5 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (820, 550, 3, 3, 40)
                    drawfilloval (840, 550, 3, 3, 40)
                    drawfilloval (820, 570, 3, 3, 40)
                    drawfilloval (840, 570, 3, 3, 40)
                    drawfilloval (830, 560, 3, 3, 40)
                elsif d1 = 6 then
                    drawfillbox (810, 540, 850, 580, 0)
                    drawfilloval (820, 550, 3, 3, 40)
                    drawfilloval (820, 560, 3, 3, 40)
                    drawfilloval (820, 570, 3, 3, 40)
                    drawfilloval (840, 550, 3, 3, 40)
                    drawfilloval (840, 560, 3, 3, 40)
                    drawfilloval (840, 570, 3, 3, 40)
                end if
                if d2 = 1 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (890, 560, 3, 3, 40)
                elsif d2 = 2 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (890, 570, 3, 3, 40)
                    drawfilloval (890, 550, 3, 3, 40)
                elsif d2 = 3 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (890, 560, 3, 3, 40)
                    drawfilloval (890, 570, 3, 3, 40)
                    drawfilloval (890, 550, 3, 3, 40)
                elsif d2 = 4 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (880, 550, 3, 3, 40)
                    drawfilloval (900, 550, 3, 3, 40)
                    drawfilloval (880, 570, 3, 3, 40)
                    drawfilloval (900, 570, 3, 3, 40)
                elsif d2 = 5 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (880, 550, 3, 3, 40)
                    drawfilloval (900, 550, 3, 3, 40)
                    drawfilloval (880, 570, 3, 3, 40)
                    drawfilloval (900, 570, 3, 3, 40)
                    drawfilloval (890, 560, 3, 3, 40)
                elsif d2 = 6 then
                    drawfillbox (870, 540, 910, 580, 0)
                    drawfilloval (880, 550, 3, 3, 40)
                    drawfilloval (880, 560, 3, 3, 40)
                    drawfilloval (880, 570, 3, 3, 40)
                    drawfilloval (900, 550, 3, 3, 40)
                    drawfilloval (900, 560, 3, 3, 40)
                    drawfilloval (900, 570, 3, 3, 40)
                end if
                dt := d1 + d2


                x5 := 40 + move
%this is the part i'm doing the movements of the players

                if turn = 1 then


                    move := (dt + odt) * 70
                    x4 := 30 + move


                    if x4 > 700 then
                        y4 := y4 + 70
                        bl := dt + odt
                        bn := (bl - 10) * 70
                        x4 := 660 - bn
                    elsif x4 < 1 then
                        y4 := y4 + 70


                    end if

                    drawfilloval (x4, y4, 10, 10, 48)
                    drawfilloval (x4_1, y4_1, 10, 10, 43)

                end if

                odt := dt
                x4_1 := x4
                y4_1 := y4
                %drawfilloval (40, 50, 10, 10, 43)
                %drawfilloval (x5, y5, 10, 10, 53)
            end if

        end if


    end loop

end dice

board
dice
>

Sponsor
Sponsor
Sponsor
sponsor
Murphman




PostPosted: Mon Dec 14, 2009 10:13 am   Post subject: Re: Snake and Ladder in turing !!! HELP PLZ !!!!!

ok i ran it again but this time the whole way through i see how it goes past 100 and keeps going you need to set a max of what it can go to
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  [ 2 Posts ]
Jump to:   


Style:  
Search: