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

Username:   Password: 
 RegisterRegister   
 How to take information from procedures and put it in another procedure/ process
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
drummaboy




PostPosted: Tue Dec 15, 2009 4:14 pm   Post subject: How to take information from procedures and put it in another procedure/ process

What is it you are trying to achieve?
I want to take infromation from a procedure or a process and be able to put the same information in
a next procedure/process Ex: an animation

What is the problem you are having?
I don't know how to do it. (The pervasive variables didn't work because it's an
animation, so it continously changes coordinates)



I know the code is long, 993 lines to be exact. But I just want to know how to take a sprites movement and
put it in a new procedure. Because i want my Sprite.Animate (in the background process)
to collided with my mario and luigi sprites in (procedure sprites)

If this sounds confusing, tell me and I'll try to explain it better

Turing:



var pervasive goombar, goombar2, goom, goom1 : int
var pervasive goomx, goomy : int
goomx := 1
goomy := 10

var pervasive hello : boolean
hello := false
var pervasive xxx : int := -20
var pervasive yyy : int := 10

process background

    loop
        drawfillbox (0, 0, maxx, maxy, 52)
        drawfillbox (0, 0, maxx, 15, brightgreen)
        %cloud 1
        drawfilloval (0, 350, 10, 10, white)
        drawfilloval (15, 350, 10, 10, white)
        drawfilloval (30, 350, 10, 10, white)
        %cloud 2
        drawfilloval (100, 350, 10, 10, white)
        drawfilloval (115, 350, 10, 10, white)
        drawfilloval (130, 350, 10, 10, white)
        %cloud 3
        drawfilloval (200, 350, 10, 10, white)
        drawfilloval (215, 350, 10, 10, white)
        drawfilloval (230, 350, 10, 10, white)
        %sun
        drawfillarc (maxx - 20, maxy - 25, 25, 50, 50, 410, yellow)






        goombar := Pic.FileNew ("goombaR.bmp")
        goom := Sprite.New (goombar)

        goombar2 := Pic.FileNew ("goombaR2.bmp")
        goom1 := Sprite.New (goombar2)

        var pervasive goombal, goombal2, goom2, goom3 : int

        goombal := Pic.FileNew ("goombaL.bmp")
        goom2 := Sprite.New (goombal)

        goombal2 := Pic.FileNew ("goombaL2.bmp")
        goom3 := Sprite.New (goombal2)

        var one : int := 0

        for l : one .. 555 by 3
            Sprite.Animate (goom, goombar, l + xxx, yyy, false)
            delay (60)
            Sprite.Animate (goom, goombar2, l + xxx, yyy, false)
            delay (60)
            Sprite.Animate (goom, goombar, l + xxx, yyy, false)

            Sprite.SetPosition (goom, goomx, goomy, false)
            Sprite.SetHeight (goom, 10)
            Sprite.Show (goom)


        end for

        for decreasing m : 552 .. 1 by 3
            xxx := 5
            Sprite.Animate (goom, goombal, m - xxx, yyy, false)
            delay (60)
            Sprite.Animate (goom, goombal2, m - xxx, yyy, false)
            delay (60)
            Sprite.Animate (goom, goombal, m - xxx, yyy, false)
        end for
        Sprite.Free (goom)

    end loop


end background

proc sprites
    Music.PlayFileLoop ("Supermariosong.mp3")

    var gen : boolean
    gen := false


    var pervasive mariostandr, mariostandl, mariowalkr, mariowalkl, mariowalkr2, mariowalkl2 : int
    var mariocfr, mariocfl, mariocfr2, mariocfl2, tunnel, platform : int
    var spr, spr1, spr2, spr3, spr4, spr5, spr6, spr7, spr8, spr9, spr10, spr11 : int
    var mariojumpr, mariojumpl, mariojumpr2, mariojumpl2, mariojumpr3, mariojumpl3 : int
    var sprite, sprite1, sprite2, sprite3, sprite4, sprite5 : int
    %mario attacks
    var mariohammerr, mariohammerl, mariohammerr2, mariohammerl2, mariohammerr3, mariohammerl3 : int
    var mariohammerr4, mariohammerl4, mariosmashr, mariosmashl, mariosmashfr, mariosmashfl : int
    var mar, mar1, mar2, mar3, mar4, mar5, mar6, mar7, mar8, mar9, mar10, mar11 : int

    % mario standing -right
    mariostandr := Pic.FileNew ("mariostandR.bmp")
    spr := Sprite.New (mariostandr)
    % mario standing -left
    mariostandl := Pic.FileNew ("mariostandL.bmp")
    spr1 := Sprite.New (mariostandl)
    % mario start walk -right
    mariowalkr := Pic.FileNew ("mariowalkR.bmp")
    spr2 := Sprite.New (mariowalkr)
    % mario start walk  - left
    mariowalkl := Pic.FileNew ("mariowalkL.bmp")
    spr3 := Sprite.New (mariowalkl)
    % mario continue walk - right
    mariowalkr2 := Pic.FileNew ("mariowalkR2.bmp")
    spr4 := Sprite.New (mariowalkr2)
    % mario continue walk - left
    mariowalkl2 := Pic.FileNew ("mariowalkL2.bmp")
    spr5 := Sprite.New (mariowalkl2)
    % mario changes foot - right
    mariocfr := Pic.FileNew ("mariocfR.bmp")
    spr6 := Sprite.New (mariocfr)
    % mario changes foot - left
    mariocfl := Pic.FileNew ("mariocfL.bmp")
    spr7 := Sprite.New (mariocfl)
    % mario change foot continued - right
    mariocfr2 := Pic.FileNew ("mariocfR2.bmp")
    spr8 := Sprite.New (mariocfr2)
    % mario change foot continues - left
    mariocfl2 := Pic.FileNew ("mariocfL2.bmp")
    spr9 := Sprite.New (mariocfl2)
    % Tunnel/Tube
    tunnel := Pic.FileNew ("tunnel.bmp")
    spr10 := Sprite.New (tunnel)
    % Platform
    platform := Pic.FileNew ("platform.bmp")
    spr11 := Sprite.New (platform)
    % mario jump - right
    mariojumpr := Pic.FileNew ("mariojumpR.bmp")
    sprite := Sprite.New (mariojumpr)
    % mario jump -left
    mariojumpl := Pic.FileNew ("mariojumpL.bmp")
    sprite1 := Sprite.New (mariojumpl)
    % mario jump - right 2
    mariojumpr2 := Pic.FileNew ("mariojumpR2.bmp")
    sprite2 := Sprite.New (mariojumpr2)
    % mario jump - left 2
    mariojumpl2 := Pic.FileNew ("mariojumpL2.bmp")
    sprite3 := Sprite.New (mariojumpl2)
    % mario jump - right 3
    mariojumpr3 := Pic.FileNew ("mariojumpR3.bmp")
    sprite4 := Sprite.New (mariojumpr3)
    % mario jump - left 3
    mariojumpl3 := Pic.FileNew ("mariojumpL3.bmp")
    sprite5 := Sprite.New (mariojumpl3)

    var tunx, tuny : int
    tunx := 550
    tuny := -5
    % put on the tunnel
    Sprite.SetPosition (spr10, tunx, tuny, false)
    Sprite.SetHeight (spr10, 10)
    Sprite.Show (spr10)

    var platx, platy : int
    platx := 300
    platy := 45
    % put on the platform
    Sprite.SetPosition (spr11, platx, platy, true)
    Sprite.SetHeight (spr11, 10)
    Sprite.Show (spr11)

    % start of mario's attacks
    %---------------------------


    % mario hammer - right
    mariohammerr := Pic.FileNew ("mariohammerR.bmp")
    mar := Sprite.New (mariohammerr)
    % mario hammer - left
    mariohammerl := Pic.FileNew ("mariohammerL.bmp")
    mar1 := Sprite.New (mariohammerl)
    % mario hammer continued 2 - right
    mariohammerr2 := Pic.FileNew ("mariohammerR2.bmp")
    mar2 := Sprite.New (mariohammerr2)
    % mario hammer continued 2 - left
    mariohammerl2 := Pic.FileNew ("mariohammerL2.bmp")
    mar3 := Sprite.New (mariohammerl2)
    % mario hammer continued 3 - right
    mariohammerr3 := Pic.FileNew ("mariohammerR3.bmp")
    mar4 := Sprite.New (mariohammerr3)
    % mario hammer continued 3 - left
    mariohammerl3 := Pic.FileNew ("mariohammerL3.bmp")
    mar5 := Sprite.New (mariohammerl3)
    % mario hammer continued 4 - right
    mariohammerr4 := Pic.FileNew ("mariohammerR4.bmp")
    mar6 := Sprite.New (mariohammerr4)
    %mario hammer continued 4 - left
    mariohammerl4 := Pic.FileNew ("mariohammerL4.bmp")
    mar7 := Sprite.New (mariohammerl4)
    % mario smash - right
    mariosmashr := Pic.FileNew ("mariosmashR.bmp")
    mar8 := Sprite.New (mariosmashr)
    % mario smash - left
    mariosmashl := Pic.FileNew ("mariosmashL.bmp")
    mar9 := Sprite.New (mariosmashl)
    % mario smash finish - right
    mariosmashfr := Pic.FileNew ("mariosmashfR.bmp")
    mar10 := Sprite.New (mariosmashfr)
    % mario smash finish - left
    mariosmashfl := Pic.FileNew ("mariosmashfL.bmp")
    mar11 := Sprite.New (mariosmashfl)

    % Mario end of hammer attacks
    % -------------------------------------------

    % start of Mario Super Smash
    %--------------------------------------------
    var mariosupersmashr, mariosupersmashl : int
    var super, super1 : int

    % Start of Mario Smash - right
    mariosupersmashr := Pic.FileNew ("mariosupersmashR.bmp")
    super := Sprite.New (mariosupersmashr)
    % Start of Mario Smash - left
    mariosupersmashl := Pic.FileNew ("mariosupersmashL.bmp")
    super1 := Sprite.New (mariosupersmashl)

    % Mario Tunnel
    %--------------------------------------------
    var mariotunnel, mariotunnel2, mariotunnel3, marioblank : int
    var martun, martun1, martun2, martun3 : int

    % Mario tunnel 1
    mariotunnel := Pic.FileNew ("mariotunnel.bmp")
    martun := Sprite.New (mariotunnel)
    % Mario tunnel 2
    mariotunnel2 := Pic.FileNew ("mariotunnel2.bmp")
    martun1 := Sprite.New (mariotunnel2)
    % Mario tunnel 3
    mariotunnel3 := Pic.FileNew ("mariotunnel3.bmp")
    martun2 := Sprite.New (mariotunnel3)
    % Mario black
    marioblank := Pic.FileNew ("marioblank.bmp")
    martun3 := Sprite.New (marioblank)


    % Mario collision
    var mariocollision, mariofall : int
    var fall, fall1 : int

    % Mario collision - with Luigi
    mariocollision := Pic.FileNew ("mariocollision.bmp")
    fall := Sprite.New (mariocollision)
    % Mario fall
    mariofall := Pic.FileNew ("mariofall.bmp")
    fall1 := Sprite.New (mariofall)


    % luigi start drawing
    %--------------------------------
    % luigi basic stepping sprites
    var luigistandr, luigistandl, luigiwalkr, luigiwalkl, luigiwalkr2, luigiwalkl2 : int
    var l, l1, l2, l3, l4, l5 : int

    % luigi stand - right
    luigistandr := Pic.FileNew ("luigistandR.bmp")
    l := Sprite.New (luigistandr)
    % luigi stand - left
    luigistandl := Pic.FileNew ("luigistandL.bmp")
    l1 := Sprite.New (luigistandl)
    % luigi walk - right
    luigiwalkr := Pic.FileNew ("luigiwalkR.bmp")
    l2 := Sprite.New (luigiwalkr)
    % luigi walk - left
    luigiwalkl := Pic.FileNew ("luigiwalkL.bmp")
    l3 := Sprite.New (luigiwalkl)
    % luigi walk 2 - right
    luigiwalkr2 := Pic.FileNew ("luigiwalkR2.bmp")
    l4 := Sprite.New (luigiwalkr2)
    % luigi walk 2 - left
    luigiwalkl2 := Pic.FileNew ("luigiwalkL2.bmp")
    l5 := Sprite.New (luigiwalkl2)

    % Start of Luigi's hammering
    %--------------------------------------
    var luigihammerr, luigihammerl, luigihammerr2, luigihammerl2, luigihammerr3, luigihammerl3 : int
    var luigihammerr4, luigihammerl4, luigihammerfinishr, luigihammerfinishl : int
    var ham, ham1, ham2, ham3, ham4, ham5, ham6, ham7, ham8, ham9 : int

    % luigi start hammering - right
    luigihammerr := Pic.FileNew ("luigihammerR.bmp")
    ham := Sprite.New (luigihammerr)
    % luigi start hammering - left
    luigihammerl := Pic.FileNew ("luigihammerL.bmp")
    ham1 := Sprite.New (luigihammerl)
    % luigi hammer continued 2 - right
    luigihammerr2 := Pic.FileNew ("luigihammerR2.bmp")
    ham2 := Sprite.New (luigihammerr2)
    % luigi hammer continued 2 - left
    luigihammerl2 := Pic.FileNew ("luigihammerL2.bmp")
    ham3 := Sprite.New (luigihammerl2)
    % luigi hammer continued 3 - right
    luigihammerr3 := Pic.FileNew ("luigihammerR3.bmp")
    ham4 := Sprite.New (luigihammerr3)
    % luigi hammer continued 3 - left
    luigihammerl3 := Pic.FileNew ("luigihammerL3.bmp")
    ham5 := Sprite.New (luigihammerl3)
    % luigi hammer continued 4 - right
    luigihammerr4 := Pic.FileNew ("luigihammerR4.bmp")
    ham6 := Sprite.New (luigihammerr4)
    % luigi hammer continued 4 - left
    luigihammerl4 := Pic.FileNew ("luigihammerL4.bmp")
    ham7 := Sprite.New (luigihammerl4)
    % luigi hammer finished - right
    luigihammerfinishr := Pic.FileNew ("luigihammerfinishR.bmp")
    ham8 := Sprite.New (luigihammerfinishr)
    % luigi hammer finished - left
    luigihammerfinishl := Pic.FileNew ("luigihammerfinishL.bmp")
    ham9 := Sprite.New (luigihammerfinishl)

    % end of luigi hammer
    %-------------------------------

    % start of luigi sit
    %-------------------------------
    var luigisitr, luigisitl : int
    var sit, sit1 : int

    % luigi sitting - right
    luigisitr := Pic.FileNew ("luigisitR.bmp")
    sit := Sprite.New (luigisitr)
    % luigi sitting - left
    luigisitl := Pic.FileNew ("luigisitL.bmp")
    sit1 := Sprite.New (luigisitl)

    % end of luigi sit
    %--------------------------------

    % start of luigi jump
    var luigijumpr, luigijumpl : int
    var jump, jump1 : int

    % luigi jumping - right
    luigijumpr := Pic.FileNew ("luigijumpR.bmp")
    jump := Sprite.New (luigijumpr)
    % luigi jumping - left
    luigijumpl := Pic.FileNew ("luigijumpL.bmp")
    jump := Sprite.New (luigijumpl)

    % start of luigi tunnel
    var luigitunnel, luigitunnel2, luigitunnel3, luigiblank : int
    var tun, tun1, tun2, tun3 : int

    % Luigi tunnel 1
    luigitunnel := Pic.FileNew ("luigitunnel.bmp")
    tun := Sprite.New (luigitunnel)
    % Luigi tunnel 2
    luigitunnel2 := Pic.FileNew ("luigitunnel2.bmp")
    tun1 := Sprite.New (luigitunnel2)
    % Luigi tunnel 3
    luigitunnel3 := Pic.FileNew ("luigitunnel3.bmp")
    tun2 := Sprite.New (luigitunnel3)
    % Luigi Blank
    luigiblank := Pic.FileNew ("luigiblank.bmp")
    tun3 := Sprite.New (luigiblank)

    % for mario direction
    var sprgen : boolean
    sprgen := true
    if sprgen = true then
        Sprite.ChangePic (spr, mariostandr)
    elsif sprgen = false then
        Sprite.ChangePic (spr, mariostandl)
    end if


    % for luigi
    var sprbol : boolean
    sprbol := true
    if sprbol = true then
        Sprite.ChangePic (l, luigistandr)
    elsif sprbol = false then
        Sprite.ChangePic (l, luigistandl)
    end if


    const ground := 10
    var gravity : int := 2
    const runspeed := 5
    var chars : array char of boolean
    var posx, posy : int
    var x, y : int
    var velx, vely : int
    var vexx, veyy : int
    posx := 21
    posy := 10
    velx := 0
    vely := 0
    vexx := 0
    veyy := 0
    x := 400
    y := 10

    var xp, yp : int
    xp := posx + 10
    yp := posy + 10

    loop
        Input.KeyDown (chars)
        % mario walking right
        if chars (KEY_RIGHT_ARROW) then


            Sprite.ChangePic (spr, mariowalkr)
            delay (60)
            Sprite.ChangePic (spr, mariowalkr2)
            posx += 5
            delay (60)
            Sprite.ChangePic (spr, mariostandr)
            sprgen := true
        end if

        % mario walking left
        if chars (KEY_LEFT_ARROW) then

            Sprite.ChangePic (spr, mariowalkl)
            delay (60)
            Sprite.ChangePic (spr, mariowalkl2)
            posx -= runspeed
            delay (60)
            Sprite.ChangePic (spr, mariostandl)
            sprgen := false

            % mario jumping
        elsif chars (KEY_UP_ARROW) and posy = 10 then

            Sprite.ChangePic (spr, mariojumpr)
            delay (200)
            Sprite.ChangePic (spr, mariojumpr2)
            delay (100)
            vely += 16
            Sprite.ChangePic (spr, mariojumpr3)
            delay (100)
            Sprite.ChangePic (spr, mariostandr)
        end if

        % mario smash right
        if chars (KEY_ENTER) and sprgen = true then

            Sprite.ChangePic (spr, mariohammerr)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr2)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr3)
            delay (60)
            Sprite.ChangePic (spr, mariosmashr)
            delay (60)
            Sprite.ChangePic (spr, mariosmashfr)
            delay (600)
            Sprite.ChangePic (spr, mariostandr)



            % mario smash left
        elsif chars (KEY_ENTER) and sprgen = false then

            Sprite.ChangePic (spr, mariohammerl)
            delay (60)
            Sprite.ChangePic (spr, mariohammerl2)
            delay (60)
            Sprite.ChangePic (spr, mariohammerl3)
            delay (60)
            Sprite.ChangePic (spr, mariosmashl)
            delay (60)
            Sprite.ChangePic (spr, mariosmashfl)
            delay (600)
            Sprite.ChangePic (spr, mariostandl)

        end if

        if chars (KEY_KEYPAD_5) and sprgen = true then
            Sprite.ChangePic (spr, mariojumpr)
        end if

        if chars (KEY_KEYPAD_5) and sprgen = false then
            Sprite.ChangePic (spr, mariojumpl)
        end if

        if chars (KEY_DOWN_ARROW) and sprgen = true then
            Sprite.ChangePic (spr, mariojumpr)
        end if

        if chars (KEY_DOWN_ARROW) and sprgen = false then
            Sprite.ChangePic (spr, mariojumpl)
        end if

        if chars (KEY_SHIFT) and sprgen = true then
            Sprite.ChangePic (spr, mariohammerr)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr2)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr3)
            delay (60)
            Sprite.ChangePic (spr, mariosmashr)
            delay (60)
            Sprite.ChangePic (spr, mariosupersmashr)
            delay (200)
            Sprite.ChangePic (spr, mariosmashfr)
            delay (600)
            Sprite.ChangePic (spr, mariostandr)

        elsif chars (KEY_SHIFT) and sprgen = false then
            Sprite.ChangePic (spr, mariohammerl)
            delay (60)
            Sprite.ChangePic (spr, mariohammerl2)
            delay (60)
            Sprite.ChangePic (spr, mariohammerl3)
            delay (60)
            Sprite.ChangePic (spr, mariosmashl)
            delay (60)
            Sprite.ChangePic (spr, mariosupersmashl)
            delay (200)
            Sprite.ChangePic (spr, mariosmashfl)
            delay (600)
            Sprite.ChangePic (spr, mariostandl)

        elsif chars (KEY_CTRL) and posx >= 550 and posy = 60 then
            Sprite.ChangePic (spr, mariotunnel)
            delay (600)
            Sprite.ChangePic (spr, mariotunnel2)
            delay (60)
            Sprite.ChangePic (spr, mariotunnel3)
            delay (60)
            Sprite.ChangePic (spr, marioblank)
        end if



        % For Luigi's Movements
        if chars ('d') then
            Sprite.ChangePic (l, luigiwalkr)
            delay (60)
            Sprite.ChangePic (l, luigiwalkr2)
            x += 5
            delay (60)
            Sprite.ChangePic (l, luigistandr)
            sprbol := true

        elsif chars ('a') then
            Sprite.ChangePic (l, luigiwalkl)
            delay (60)
            Sprite.ChangePic (l, luigiwalkl2)
            x -= 5
            delay (60)
            Sprite.ChangePic (l, luigistandl)
            sprbol := false
        end if

        % If you press b and sprbol is true (facing right) then you
        % hammer right
        if chars ('b') and sprbol = true then
            Sprite.ChangePic (l, luigihammerr)
            delay (60)
            Sprite.ChangePic (l, luigihammerr2)
            delay (60)
            Sprite.ChangePic (l, luigihammerr3)
            delay (60)
            Sprite.ChangePic (l, luigihammerr4)
            delay (60)
            Sprite.ChangePic (l, luigihammerfinishr)
            delay (600)
            Sprite.ChangePic (l, luigistandr)

% If you press 'b' and sprbol is false (facing left) then you
% hammer left
        elsif chars ('b') and sprbol = false then
            Sprite.ChangePic (l, luigihammerl)
            delay (60)
            Sprite.ChangePic (l, luigihammerl2)
            delay (60)
            Sprite.ChangePic (l, luigihammerl3)
            delay (60)
            Sprite.ChangePic (l, luigihammerl4)
            delay (60)
            Sprite.ChangePic (l, luigihammerfinishl)
            delay (600)
            Sprite.ChangePic (l, luigistandl)
        end if

        if chars ('s') and sprbol = true then
            Sprite.ChangePic (l, luigisitr)

        elsif chars ('s') and sprbol = false then
            Sprite.ChangePic (l, luigisitl)
        end if

        if chars ('w') and y = 10 then
            Sprite.ChangePic (l, luigijumpr)
            delay (60)
            Sprite.ChangePic (l, luigijumpr)
            veyy += 17
        end if

        if chars ('n') and x >= 550 and y = 60 then
            Sprite.ChangePic (l, luigitunnel)
            delay (600)
            Sprite.ChangePic (l, luigitunnel2)
            delay (60)
            Sprite.ChangePic (l, luigitunnel3)
            delay (60)
            Sprite.ChangePic (l, luigiblank)
        end if


        vely -= gravity
        posx += round (velx)
        posy += round (vely)

        veyy -= gravity
        x += ceil (vexx)
        y += ceil (veyy)

        % luigi stuff ------------------------------
        if y < 10 then
            y := 10
            veyy := 0

        elsif y > 65 and x > 150 and x < 450 then
            y := 65
            veyy := 0
            gravity := 0
        else
            gravity := 1
        end if

        if y = 65 and x < 150 then
            gravity := 1
        end if

        if x >= 400 and y = 65 then
            y := ground
            gravity := 1

        elsif x >= 550 and y >= 60 then
            y := 60
            gravity := 0
        else
            gravity := 1
        end if




        % end of luigi stuff -------------------------------
        var arr : array 10 .. 20 of int

        if posy < ground then
            posy := ground
            vely := 0
        end if

        if posy > 65 and posx > 150 then
            posy := 65
            gravity := 0

        elsif posy = 65 and posx <= 150 then
            gravity := 1
        end if

        if posy = 65 and posx >= 400 then
            gravity := 1
        end if


        if x > 150 and y >= 65 then
            y := 65
            gravity := 0

        elsif x <= 150 and y = 65 then
            gravity := 1

        elsif x >= 400 and y = 65 then
            gravity := 1
        end if

        if posx = -20 then
            posx += maxx - 20
            Sprite.ChangePic (spr, mariostandl)

        elsif posx = maxx + 20 then
            posx := posx - 20
            Sprite.ChangePic (spr, mariostandr)

        elsif x = maxx + 20 then
            x := -20

        elsif x = -20 then
            x := maxx + 20
        end if

        if chars ('z') then
            gen := true
        elsif chars ('x') then
            gen := false
        end if


        % Math Distance stuff


        if Math.Distance (posx, posy, x, y) <= 15 and gen = true then
            posx -= 10
            Sprite.ChangePic (spr, mariocollision)
            delay (60)
            Sprite.ChangePic (spr, mariofall)
            delay (600)
            Sprite.ChangePic (spr, mariostandr)

        elsif Math.Distance (posx, posy, tunx, tuny) <= 15 then
            posx -= 10

        elsif Math.Distance (x, y, 500, -5) <= 15 then
            x -= 10

        elsif Math.Distance (posx, posy, xxx, yyy) <= 10 then
            put "ow"

        end if


        %drawing the sprite
        Sprite.SetPosition (spr, posx, posy, false)
        Sprite.SetHeight (spr, 10)
        Sprite.Show (spr)

        Sprite.SetPosition (l, x, y, false)
        Sprite.SetHeight (l, 10)
        Sprite.Show (l)







        % search up pic width - collision detection

    end loop
end sprites







proc mainmenu

    drawfillbox (0, 0, maxx, maxy, 52)
    colorback (52)
    drawfillbox (0, 0, maxx, 10, brightgreen)

    Music.PlayFileStop



    Music.PlayFileLoop ("mario.mp3")

    var mari : int
    var mar : int

    var num : int
    var fnt : int
    fnt := Font.New ("Bookman Old Style:25")

    Draw.Text ("Super Mario Advanced!!!", 150, 350, fnt, brightred)
    delay (600)
    locate (5, 20)
    Text.Color (255)
    put "To play the game press 1"
    locate (7, 20)
    Text.Color (12)
    put "To see the controls press 2"
    locate (9, 20)
    Text.Color (15)
    put "to exit press 3"

    get num


    if num = 1 then
var xx :int
var yy :int
xx := 10
yy:= 10
       
        hello := true
        locate (25,1)
        put "loading . . ."
        for m : 1..maxx by 10
        drawfillbox (0,0,xx+ m,yy ,black)
        delay (60)
        end for
        Music.PlayFileStop
        fork background
        sprites

    elsif num = 2 then
        var mariopic, luigipic : int
        drawfillbox (0, 0, maxx, maxy, black)
        colorback (black)
        mariopic := Pic.FileNew ("image1.bmp")
        luigipic := Pic.FileNew ("image2.bmp")
        Pic.Draw (mariopic, 5, 250, picCopy)
        Pic.Draw (luigipic, maxx - 100, 0, picCopy)
        var chars : string (1)

        loop
            delay (100)
            locate (1, 15)
            Text.Color (0)
            put "-Use the left and right arrow keys"
            locate (2, 15)
            put "or the numpad(4 and 6) to move Mario"
            delay (100)
            locate (3, 15)
            Text.Color (13)
            delay (100)
            put "-Press the enter key to use your hammer" ..
            locate (4, 15)
            delay (100)
            put "-Press the shift key to do a super hammer attack" ..
            locate (5, 15)
            Text.Color (76)
            delay (100)
            put "- press the up arrow or 8 on the numpad" ..
            locate (6, 15)
            delay (100)
            put "to jump. Also press which direction you want to go" ..
            locate (7, 15)
            Text.Color (48)
            delay (100)
            put "to crouch press down or 5 on the numpad" ..
            locate (8, 15)
            delay (100)
            put "-to enter the tunnel press the control key" ..
            locate (16, 1)
            Text.Color (103)
            delay (100)
            put "-To move Luigi use 'A' and 'D'" ..
            locate (17, 1)
            Text.Color (40)
            delay (100)
            put "-To make Luigi jump, press 'W' + ('A' or 'D')" ..
            locate (18, 1)
            Text.Color (64)
            delay (100)
            put "-To use the hammer click 'B'" ..
            locate (19, 1)
            Text.Color (36)
            delay (100)
            put "-To sit down, press 'S' " ..
            locate (20, 1)
            delay (100)
            put "-To go in the tunnel, press 'N'" ..
            locate (13, 1)
            Text.Color (0)
            delay (100)
            put "To go back to the menu, press M"
            loop
                getch (chars)
                if chars = ("m") then
                    mainmenu
                end if
            end loop
        end loop
    end if

    if num = 3 then
        drawfillbox (0, 0, maxx, maxy, black)
        Draw.Text ("Bye", 250, maxy div 2, fnt, brightred)
        quit
    end if

end mainmenu

process mariomenu
    var x, y : int
    x := -40
    y := 10

    var pervasive mariostandr, mariostandl, mariowalkr, mariowalkl, mariowalkr2, mariowalkl2 : int
    var mariocfr, mariocfl, mariocfr2, mariocfl2, tunnel, platform : int
    var spr, spr1, spr2, spr3, spr4, spr5, spr6, spr7, spr8, spr9, spr10, spr11 : int
    var mariojumpr, mariojumpl, mariojumpr2, mariojumpl2, mariojumpr3, mariojumpl3 : int
    var sprite, sprite1, sprite2, sprite3, sprite4, sprite5 : int
    %mario attacks
    var mariohammerr, mariohammerl, mariohammerr2, mariohammerl2, mariohammerr3, mariohammerl3 : int
    var mariohammerr4, mariohammerl4, mariosmashr, mariosmashl, mariosmashfr, mariosmashfl : int
    var mar, mar1, mar2, mar3, mar4, mar5, mar6, mar7, mar8, mar9, mar10, mar11 : int

    % mario standing -right
    mariostandr := Pic.FileNew ("mariostandR.bmp")
    spr := Sprite.New (mariostandr)
    % mario standing -left
    mariostandl := Pic.FileNew ("mariostandL.bmp")
    spr1 := Sprite.New (mariostandl)
    % mario start walk -right
    mariowalkr := Pic.FileNew ("mariowalkR.bmp")
    spr2 := Sprite.New (mariowalkr)
    % mario start walk  - left
    mariowalkl := Pic.FileNew ("mariowalkL.bmp")
    spr3 := Sprite.New (mariowalkl)
    % mario continue walk - right
    mariowalkr2 := Pic.FileNew ("mariowalkR2.bmp")
    spr4 := Sprite.New (mariowalkr2)
    % mario continue walk - left

    loop


        for l : 1 .. maxx + 30 by 5
            Sprite.Animate (spr, mariowalkr, x + l, y, false)
            delay (60)
            Sprite.Animate (spr, mariowalkr2, x + l, y, false)
            delay (60)
            Sprite.Animate (spr, mariostandr, x + l, y, false)

            Sprite.SetPosition (spr, x, y, false)
            Sprite.SetHeight (spr, 10)
            Sprite.Show (spr)

            if hello = true then

                exit
            end if
        end for


    end loop

end mariomenu

process luigimenu
 var luigistandr, luigistandl, luigiwalkr, luigiwalkl, luigiwalkr2, luigiwalkl2 : int
    var l, l1, l2, l3, l4, l5 : int

    % luigi stand - right
    luigistandr := Pic.FileNew ("luigistandR.bmp")
    l := Sprite.New (luigistandr)
    % luigi stand - left
    luigistandl := Pic.FileNew ("luigistandL.bmp")
    l1 := Sprite.New (luigistandl)
    % luigi walk - right
    luigiwalkr := Pic.FileNew ("luigiwalkR.bmp")
    l2 := Sprite.New (luigiwalkr)
    % luigi walk - left
    luigiwalkl := Pic.FileNew ("luigiwalkL.bmp")
    l3 := Sprite.New (luigiwalkl)
    % luigi walk 2 - right
    luigiwalkr2 := Pic.FileNew ("luigiwalkR2.bmp")
    l4 := Sprite.New (luigiwalkr2)
    luigiwalkl2 := Pic.FileNew ("luigiwalkL2.bmp")
    l5 := Sprite.New (luigiwalkl2)
   
    var x:= maxx +30
    var y:= 10
   
   
    loop
    for m : 1 ..maxx + 70 by 5
    Sprite.Animate (l, luigiwalkl, x-m, y, false)
            delay (60)
            Sprite.Animate (l, luigiwalkl2, x-m, y, false)
            delay (60)
            Sprite.Animate (l, luigistandl, x-m, y, false)

            Sprite.SetPosition (l, x, y, false)
            Sprite.SetHeight (l, 10)
            Sprite.Show (l)
if hello = true then

                exit
            end if
           
            end for
end loop
   
   
end luigimenu

fork luigimenu
fork mariomenu
mainmenu



Please specify what version of Turing you are using
4.1.1
 
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Dec 15, 2009 6:44 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

That... a lot of code. You might want to invest some time into getting familiar with arrays and for-loops.

I'm not sure what you are asking about. From the title I could try to guess that it's about functions (procedures that return values that you can use elsewhere), but I suspect that you are just not making yourself clear.

P.S. When your game starts crashing and telling you that you are out of available picture IDs, or something along those lines, you might learn not to load the _same_ images inside a loop. Or at least of Pic.Free
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
mirhagk




PostPosted: Wed Dec 16, 2009 8:28 am   Post subject: RE:How to take information from procedures and put it in another procedure/ process

your code is really long, and not built right at all. I don't have time to look it over right now, but if you send me the pics with the program I can help you out with it in my period 3 class today.

For now listen to what tony said about looking up arrays and for loops, I'm definetly going to use them to help you out so you should know them.

I don't quite get what your asking though because as long as a variable is global (not declared within a procedure) then anything can use the variable at any time within your code.

Also using processes is a bad thing 99.9999% of the time, you might want to investigate whether you need them in seperate processes or not
 
drummaboy




PostPosted: Wed Dec 16, 2009 12:08 pm   Post subject: Re: How to take information from procedures and put it in another procedure/ process

Here is the file with all the pictures and such


Mario_advanced_redone.zip
 Description:

Download
 Filename:  Mario_advanced_redone.zip
 Filesize:  2.15 MB
 Downloaded:  128 Time(s)

 
drummaboy




PostPosted: Wed Dec 16, 2009 12:12 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

And what I'm trying to say is that.

I have a sprite animation (in process background) and it works fine and all.

But I have my moveable characters in a procedure called "procedure sprites"

how do I make it so that my characters can collided with the animation?

I know how to make a varibale global but the sprite keeps on moving so then the x distance is constantly changing.

So how can I get it so that I can detect the movement of my sprite and make it interact with luigi and mario
 
mirhagk




PostPosted: Wed Dec 16, 2009 12:32 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

as long as the x position is in some sort of variable (which it should be) and you know collision detection then it shouldn't be difficult at all
 
drummaboy




PostPosted: Wed Dec 16, 2009 1:30 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

it is. but the x continues to change position. and I want them to collided but they're in 2 different procedures. So I need to do something to detect the movement of my enemy and bring that information and put in in my other procedure
 
drummaboy




PostPosted: Wed Dec 16, 2009 4:21 pm   Post subject: Re: How to take information from procedures and put it in another procedure/ process

also,. I searched up arrays, but I don't know how they could helo me out
 
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Wed Dec 16, 2009 4:27 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

you could store the pictures in arrays (one for each character). Also store the sprites in arrays. instead of
Turing:

if chars (KEY_SHIFT) and sprgen = true then
            Sprite.ChangePic (spr, mariohammerr)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr2)
            delay (60)
            Sprite.ChangePic (spr, mariohammerr3)
            delay (60)
            Sprite.ChangePic (spr, mariosmashr)
            delay (60)
            Sprite.ChangePic (spr, mariosupersmashr)
            delay (200)
            Sprite.ChangePic (spr, mariosmashfr)
            delay (600)
            Sprite.ChangePic (spr, mariostandr)
end if

you could have just
Turing:

if chars (KEY_SHIFT) and sprgen = true then
for i:1..5
Sprite.ChangePic (spr, mario(i))
            delay (60)
end for
end if

it will make your code MUCH shorter and ALOT easier to maintain
 
drummaboy




PostPosted: Wed Dec 16, 2009 4:29 pm   Post subject: Re: How to take information from procedures and put it in another procedure/ process

wow ... it's much shorter but can you explain what you did?? How did you make it so that it can detect what sprites I want to change it to?
 
TheGuardian001




PostPosted: Wed Dec 16, 2009 4:42 pm   Post subject: Re: How to take information from procedures and put it in another procedure/ process

He made it into an array. It's basically a collection of variables. We have a nice tutorial on them right over here.
 
mirhagk




PostPosted: Wed Dec 16, 2009 4:46 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

check out the linked tutorial. do a few random programs to get the hang of arrays. Then look for every opportunity you get to use them. Anywhere you see similar code being run you can use for loops and arrays.
 
drummaboy




PostPosted: Wed Dec 16, 2009 4:47 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

How would I do it with sprites though? Like I see the code but I don't understand how I'd get the pictures in the array
 
mirhagk




PostPosted: Wed Dec 16, 2009 4:53 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

just load the pictures normally except reference the array like the following example
Turing:

var pic:array 1..5 of int
pic(1):=Pic.FileNew("my1pic")
pic(2):=Pic.FileNew("my2pic")
pic(3):=Pic.FileNew("my3pic")
pic(4):=Pic.FileNew("my4pic")
pic(5):=Pic.FileNew("my5pic")
 
drummaboy




PostPosted: Wed Dec 16, 2009 4:58 pm   Post subject: RE:How to take information from procedures and put it in another procedure/ process

oh thanks mirhagk... your the best.

and thanks for not getting impatient with me
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: