
-----------------------------------
drummaboy
Tue Dec 15, 2009 4:14 pm

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




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 = 400 then
            gravity := 1
        end if


        if x > 150 and y >= 65 then
            y := 65
            gravity := 0

        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) 