
-----------------------------------
florayu
Tue Nov 16, 2010 4:51 pm

multiple loops. D:
-----------------------------------
What is it you are trying to achieve?

So, for my gr 10 programming class, we're supposed to create an animation with 2 sprites. both moving. 

What is the problem you are having?
I looped the first sprite so it goes in a continuous and repeated motion . Im trying to get my 2nd sprite to do a different motion at the same time, but i realized that the sprite only runs after my first loop ends. Does anyone know if you can run two loops at the same time, and how to do it?

-----------------------------------
TerranceN
Tue Nov 16, 2010 5:08 pm

RE:multiple loops. D:
-----------------------------------
Instead of running two loops at the same time, have one loop where you move both objects and draw both objects. That way every time the loop goes around, both objects will move and get drawn.

Something like

loop
    % Move both objects

    cls
    % Draw both objects
end loop


Hope that helps.

-----------------------------------
florayu
Tue Nov 16, 2010 5:36 pm

Re: multiple loops. D:
-----------------------------------
my code looks like this : 
loop
counter := counter + 1 
    piplupRight := Pic.FileNew ("piplup_right.bmp")
    piplupRight := Pic.Scale (piplupRight, 40, 50)
    piplupRight := Sprite.New (piplupRight)
    piplupLeft := Pic.FileNew ("piplup_left.bmp")
    piplupLeft := Pic.Scale (piplupLeft, 40, 50)
    piplupLeft := Sprite.New (piplupLeft)
    loop
        Sprite.SetPosition (piplupRight, w, x, false)
        w := w + 1
        Sprite.Show (piplupRight)
        delay (7)
        Sprite.Hide (piplupRight)
        exit when w = 230
    end loop
    loop
        Sprite.SetPosition (piplupRight, w, x, false)
        x := x - 1
        Sprite.Show (piplupRight)
        delay (7)
        Sprite.Hide (piplupRight)
        exit when x 