
-----------------------------------
Demagogue
Fri May 16, 2008 5:02 pm

Looping Issues: Procedure Blockage
-----------------------------------
The problem with a program is that, when used as a procedure, it blocks all procedures that come after it. And I see the problem, the loop within is still running. But if I don't run it, the animation on the buttons (colour change on hover) won't run and would make the whole effort worth nothing. How do I tackle this?

setscreen ("graphics:600,600,offscreenonly")

procedure menu

    var a, b, c, d, e := 16
    var x, y, m : int
    var x1, y1, m1 : int
    m := 0
  
    var menu1, menu2, menu3, menu4 : int
    menu1 := Font.New ("Comicsans:30:bold")
    menu2 := Font.New ("Comicsans:18:bold")
    menu3 := Font.New ("Comicsans:22:bold")
    menu4 := Font.New ("Comicsans:22:bold")
    %Play

   loop
        View.Update

        drawfillbox (240, 340, 390, 400, a)
        Font.Draw ("Play", 275, 360, menu1, white)
        Mouse.Where (x, y, m)
        if x > 240 and x < 390 and y > 340 and y < 400 then
            a := 41
        else
            a := 7
        end if
        %
        drawfillbox (240, 270, 390, 320, b)
        Font.Draw ("Instructions", 245, 290, menu2, white)
        Mouse.Where (x, y, m)
        if x > 240 and x < 390 and y > 270 and y < 320 then
            b := 41
        else
            b := 16
        end if
        %
        drawfillbox (240, 210, 390, 260, c)
        Font.Draw ("Concept", 265, 230, menu2, white)
        Mouse.Where (x, y, m)
        if x > 240 and x < 390 and y > 210 and y < 260 then
            c := 41
        else
            c := 16
        end if

        drawfillbox (240, 150, 390, 200, d)
        Font.Draw ("About", 280, 170, menu2, white)
        Mouse.Where (x, y, m)
        if x > 240 and x < 390 and y > 150 and y < 200 then
            d := 41
        else
            d := 16
        end if

  

end loop

end menu

-----------------------------------
riveryu
Fri May 16, 2008 7:06 pm

Re: Looping Issues: Procedure Blockage
-----------------------------------
Hi, Demagogue

I think you can solve the problem by putting an exit when (mouse clicked a  button) . 
Furthermore, record down which button the user clicked, then exit the loop, using if and then determine wat to do after.
 Ex. user clicks play, exits menu, if (user clicked instructions) then (lauch instructions)end if. Anytime you want to return to menu, just reset variables  and lauch menu again.

Hope this helps. Sry if it doesnt.[/b]
