Computer Science Canada

How could you make a GUI like this one....

Author:  rbb [ Fri May 09, 2003 10:02 am ]
Post subject:  How could you make a GUI like this one....

How do you make a custom GUi but with different button formations and differnts background colors.
Like this one
2D shooter game
6 Homer_simpson 183 Sat Apr 26, 2003 12:38 pm
Homer_simpson
It's on the submission forum

Author:  Homer_simpson [ Fri May 09, 2003 11:18 am ]
Post subject: 

try http://www.compsci.ca/bbs/viewtopic.php?t=623
I have put all the Custom GUI that i used in 2D shooter in there... if you need any help with using them just lemme know...

Author:  rbb [ Mon May 12, 2003 8:37 am ]
Post subject:  Okay I need some help here...

Alright I was just wondering how you made your layout for that spaceship game so centered and looked good. I tried to use your custom GUI thing and all I can get is the button thing on the left side. I just need some assistance on how to center it and make it look decently presentable.

Author:  Homer_simpson [ Mon May 12, 2003 12:57 pm ]
Post subject: 

ok... for that you need another one of my functions
code:
var bfont : int := Font.New ("System:12")
var menu1 := 0
function mouseover (x1, y1, x2, y2 : int) : boolean
    var mousex, mousey, mouseb : int
    mousewhere (mousex, mousey, mouseb)
    if mousex >= x1 and mousex <= x2 then
        if mousey >= y1 and mousey <= y2 then
            result true
        end if
    end if
    result false
end mouseover

procedure button (x1, y1, x2, y2, c, tc : int, s : string, num : int, var i : int, font : int, b : boolean)
    var mousex, mousey, mouseb : int
    mousewhere (mousex, mousey, mouseb)

    if mouseover (x1, y1, x2, y2) then
        drawline (x1, y1, x2, y1, 30)
        drawline (x2, y1, x2, y2, 30)
        drawline (x2, y2, x1, y2, 25)
        drawline (x1, y2, x1, y1, 25)
        if mouseb = 1 then
            i := num
            drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, 1)
            Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2) + 1, ((y1 + ((y2 - y1) div 2)) - 4) - 1, font, 14)
        else
            drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, c)
            Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2) + 1, ((y1 + ((y2 - y1) div 2)) - 4) - 1, font, tc)
        end if
    else
        drawline (x1, y1, x2, y1, 25)
        drawline (x2, y1, x2, y2, 25)
        drawline (x2, y2, x1, y2, 30)
        drawline (x1, y2, x1, y1, 30)
        drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, c)
        Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2), (y1 + ((y2 - y1) div 2)) - 4, font, tc)
    end if
end button

function menu (num, x1, x2, y1, ksp, dssp, c1, c2 : int, s : array 1 .. * of string) : int
    var dsp := 0
    dsp := ksp + dssp - 10
    var res := 0
    var ii : int := num
    for i : 1 .. num * 10 by 10
        if (i div 10) not= num then

            button (x1, (y1 + (dsp * (i div 10))) + i, x2, y1 + ((dsp * (i div 10)) + i) + ksp, c1, 7, s (ii), ii, res, bfont, true)
        else
            button (x1, (y1 + (dsp * (i div 10))) + i, x2, y1 + ((dsp * (i div 10)) + i) + ksp, c2, 14, s (ii), ii, res, bfont, false)
        end if
        ii := ii - 1
    end for
    result res
end menu

View.Set ("offscreenonly")
var menutext : array 1 .. 6 of string
menutext (1) := "text 1"
menutext (2) := "text 2"
menutext (3) := "text 3"
menutext (4) := "text 4"
menutext (5) := "text 5"
loop
    locate (1, 1)
    put "menu # ", menu (5, 220, 420, 150, 20, 10, 8, 9, menutext), " selected..."
    View.Update
    delay (10)
end loop


you have to know how to use menu function... here are the instructions:
function menu (num, x1, x2, y1, ksp, dssp, c1, c2 : int, s : array 1 .. * of string) : int


num is the number of options the menu will have (in my example 5)
x1 is where in x grid the menu starts
x2 is where in x grid the menu ends
y1 is where in y grid the menu starts(y2 will be caclulated depending on number of options and distances between them...)
ksp indicates how tall each buttons is
dssp sets the space between each button
c1 is the color 1(when mouse is not over)
c2 is the color 2(when mouse is over)
s is an array of string which will be used to set the text for the buttons
you have to declare a variable like this
var menutext:array 1..numberofoptions of string
and then give it value like this
menutext(1):="blah blah"
menutext(2):="blah blah"
menutext(3):="blah blah"
.
.
.
if anymore questions please ask...

Author:  rbb [ Tue May 13, 2003 8:41 am ]
Post subject:  To cahnge teh background color do you...

To change the background color do you use drawfill and things like that and to have the button link to another page;. How do you do these things

Author:  Homer_simpson [ Tue May 13, 2003 4:39 pm ]
Post subject: 

well just use an if statement and say like :
code:
if menu1=1 then
cls
loop
blah blah blah
exit when blah
end loop
end if
if menu1=2 then
cls
blah blah
end if


: