summative
Author |
Message |
gh0stz
|
Posted: Mon May 29, 2006 6:09 pm Post subject: summative |
|
|
i have a school summative where i have make an electronical catalogue.
is there a way for me to use the gui (menu bar) and put a picture in? From what i have tried it doesn't work.
code: | import GUI
View.Set("nobuttonbar")
var action : int
var item : array 1 .. 4 of int
var name : array 1 .. 4 of string := init ("Quit", "Restart", "Finished", "Cart")
var picID : int
procedure MenuSelect
for i : 1 .. 4
if item (i) = GUI.GetEventWidgetID then
Text.Locate (maxrow, 1)
put "You picked" + name (i) ..
end if
end for
end MenuSelect
action := GUI.CreateMenu ("Action")
item (1) := GUI.CreateMenuItem (name (1), GUI.Quit)
for i : 2 .. 4
item (i) := GUI.CreateMenuItem (name (i), MenuSelect)
end for
loop
exit when GUI.ProcessEvent
end loop
picID := Pic.FileNew ("checkout.jpg")
Pic.Draw (picID, 0, 0, 0)
|
thats what i have so far, please help |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Mon May 29, 2006 6:24 pm Post subject: (No subject) |
|
|
Hello.
In future, please use more descriptive topic titles that "summative". This tells us nothing about the nature of your problem and hence fewer people will be interested in looking at your thread. It's for your own benefit, really.
I'm not entirely sure I understood your question, as it was a little vaguely phrased (mind you, not as bad as they get). Am I to believe that you want to be able to access GUI objects while at the same time drawing pictures where necassary? Perhaps background pics or the like?
This is quite possible. Keep in mind that your final loop will contain GUI.ProcessEvent, and essentially that is an infinite loop that will only terminate when GUI.Quit is called.
Therefore, any other sorts of things that you feel like doing should be done before that loop, or in some cases, in that loop itself.
pseudo: |
declare GUI streams
declare GUI procs
implement GUI
draw picture
loop
exit when GUI.ProcessEvent
end loop
% Or...
loop
current_time := Time.Elapsed
if last_time - current_time > delay_factor then
draw picture
last_time := Time.Elapsed
% This little ditty draws a picture within the loop, but refreshes it at certain intervals.
% Intervals are useful since it saves having to redraw a picture several hundred times a second - which would be inefficient!
end if
|
If that didn't answer your question, be a little more specific and we'll see what we can do. |
|
|
|
|
![](images/spacer.gif) |
gh0stz
|
Posted: Mon May 29, 2006 7:20 pm Post subject: (No subject) |
|
|
note taken delos
but i'm not quite understanding the concept behind the second part of your code that goes
code: | loop
current_time := Time.Elapsed
if last_time - current_time > delay_factor then
draw picture
last_time := Time.Elapsed
% This little ditty draws a picture within the loop, but refreshes it at certain intervals.
% Intervals are useful since it saves having to redraw a picture several hundred times a second - which would be inefficient!
end if |
what does the current_time:= Time.Elasped do? basically.. i don't understand the whole second thing or how to impliment delay_factor or current_time.
thanks for your help so far |
|
|
|
|
![](images/spacer.gif) |
HellblazerX
![](http://www.plamania.co.kr/shopimages/plmtest/2910040000213.jpg)
|
Posted: Mon May 29, 2006 8:59 pm Post subject: (No subject) |
|
|
It's a fps (frames per second) limiter. Basically, it makes it so the image is only drawn at certain time intervals, rather than everytime the program loops. Like for example, in his code, if you set the variable delay_factor to 500, it will draw the images every 500 milliseconds, or draws twice every second, and thus you get 2 fps. What the Time.Elapsed function does is it returns the number of milliseconds that has passed since the program began. In his code, Delos keeps track of the time he drew the image last time, and when the time interval is up, he draws the image again, and saves the time, and so on and so on.
Btw, Delos, you don't need the currentTime := Time.Elapsed seeing as you're only calling it once. You can have the Time.Elapsed inside the if statement. Also, it's more accurate this way because there is that tiny portion of time it takes to read the next line. ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|