Computer Science Canada

Need Help With Menu Item In Loop

Author:  Siavash [ Mon Apr 06, 2009 6:03 pm ]
Post subject:  Need Help With Menu Item In Loop

I made a animated program that is in an infinite loop and I need to use the GUI.CreateMenu command in my loop with menu items. I've done that, but how can have it in the loop so that is updates the Menu instead of having it create a MenuItem each time it goes through the loop?

Author:  Dusk Eagle [ Mon Apr 06, 2009 6:30 pm ]
Post subject:  Re: Need Help With Menu Item In Loop

It'd be really helpful to see the code before we attempt to answer your question. Type in [syntax="turing"] [/syntax] and stick the code in between the pairs of square brackets.

Author:  Siavash [ Mon Apr 06, 2009 7:05 pm ]
Post subject:  Re: Need Help With Menu Item In Loop

Turing:
import GUI

View.Set ("graphics:250;150,nobuttonbar,offscreenonly")
var first : int       % The menus.
var item : int % The menu items.
var m, p : int := 1

var name : string (20) := "Quit"

% Create the menus
first := GUI.CreateMenu ("First")
item := GUI.CreateMenuItem (name, GUI.Quit)

loop
    if p = maxx then
        m := -m
    end if
    if p < 0 then
        m := -m
    end if
    p := p + m
    drawfillbox (p, 100, p + 10, 110, black)
    exit when GUI.ProcessEvent
    View.Update
    cls
end loop


if i put :first := GUI.CreateMenu ("First") and item := GUI.CreateMenuItem (name, GUI.Quit) in the loop, it creates new menu each time and if i dont (like example), it goes away

Author:  Dusk Eagle [ Tue Apr 07, 2009 11:45 pm ]
Post subject:  Re: Need Help With Menu Item In Loop

I'll admit to not being familiar with Turing's GUI. Therefore, the method I suggest may not be the best way, but it will get the job done.

Remove the cls, View.Update, and offscreenonly commands. Now, every time through the loop, before you update the box's variables, draw a background-color colored box in the same location as you drew your last black box. This will prevent the GUI from ever being cleared from the screen, as you will never call cls in the first place.

Author:  Siavash [ Sat Apr 11, 2009 7:38 am ]
Post subject:  RE:Need Help With Menu Item In Loop

that makes it flicker for my actual game that i am making.
post moved to: http://compsci.ca/v3/viewtopic.php?t=20678


: