Procedures in the GUI
Author |
Message |
Wilcroft
|
Posted: Fri Apr 18, 2008 4:42 pm Post subject: Procedures in the GUI |
|
|
I'm looking for some assistance.
I'm trying right now to build a game for G11, and I'm basically writing a build screen for attributes and whatnot, using the GUI. I (from what I've read/experience) realize that the GUI is not great, but due to time constraints, etc. I can't write my own.
Here's my basic problem. I want to have one or two procedures that work for all attributes, but in the GUI.CreateButton call, the procedure field doesn't seem to accept parameters. Is this just me, or is this the GUI?
here's my basic code:
Turing: | import GUI
type shipdata :
record
armor : int
shield : int
laser : boolean
laserstr : int
missle : boolean
misslenum : int
fighters : boolean
hangers : int
scanrange : int
speed : int
size : int
pointdef : boolean
pdstrength : int
end record
var p1ships : flexible array 1 .. 1 of shipdata
var total:= 20
p1ships (1).armor := 0
proc add %(var num : int)
p1ships (1).armor + = 1
total-= 1
if total < 0 then
total += 1
p1ships (1).armor -= 1
end if
Text.Locate (2, 3)
put p1ships (1).armor
put total
end add
var quitButton : int := GUI.CreateButton (10, 10, 0, "Quit", GUI.Quit)
var addarmor := GUI.CreateButton (10, 35, 0, "+1", add )
loop
exit when GUI.ProcessEvent
end loop
|
I want to instead change it to add(p1ships(1).armor), so I can use the same procedure for all the variables. Could someone tell me if this is possible, or possibly hook me up with a way to make it work? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Fri Apr 18, 2008 4:54 pm Post subject: RE:Procedures in the GUI |
|
|
you can't it's the GUI, however you could make it call a procedure which calls your procedure:
code: | proc this(x,y:int)
end this
proc foo
this(20,40)
end foo
var addarmor := GUI.CreateButton (10, 35, 0, "+1", foo )
|
|
|
|
|
|
![](images/spacer.gif) |
Wilcroft
|
Posted: Fri Apr 18, 2008 5:29 pm Post subject: Re: Procedures in the GUI |
|
|
thanks Nick. through your help, and ideas from my dad, I have figured it out using multiple buttons, which was the basis of my problem. I've managed to reduce my procedure count from 16 to 4! Wheee! |
|
|
|
|
![](images/spacer.gif) |
|
|