
-----------------------------------
air_force91
Sat Jan 10, 2004 1:27 pm

buttons and clicks
-----------------------------------
ive made buttons and stuff...but i don't know how to make a code for the user to click anywhere inside the buttons and be taken to specific pages...here's my code:

setscreen ("graphics:800;350")

colourback (3)
cls


%2nd page

var size : int
var text1 : string
size := 15
var text := "The PAGE!!!"

var afontID : array 1 .. size of int

for i : size div 2 .. size
    afontID (i) := Font.New ("Tahoma:" + intstr (i))

end for


procedure Text3D (text : string)

    for t : 1 .. length (text)

        for i : size div 2 .. size
            Font.Draw (text (t), t * size, 315, afontID (i), 20 + floor
                (i / size * 10))

        end for
    end for

end Text3D

Text3D (text)

%%Import computer picture

var comppic : int := Pic.FileNew ("comp3.bmp")
Pic.Draw (comppic, 50 div 2, 20 div 2, 0)


%%%%%%%%%%%%%%%%%%%%%%buttons

%3rd button

Draw.FillBox (550, 40, 667, 90, 5)

var bfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Exit", 590, 60, bfontID, black)

%2nd button

Draw.FillBox (550, 140, 667, 190, 5)

var cfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Start", 562, 160, cfontID, black)

%1st button

Draw.FillBox (550, 240, 667, 290, 5)

var dfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Music", 562, 260, dfontID, black)

%%%mouse detect--*click*

var ch : string (1)
var x, y, btnnum, btnupdown : int
x := 562
y := 260
loop
    if hasch then
        getch (ch)


    end if
    if Mouse.ButtonMoved ("down") then
        Mouse.ButtonWait ("down", x, y, btnnum, btnupdown)
Text.Locate (21, 100)

        cls


    end if
end loop


if u have any suggestions so i can improve the look of my page or the buttons...pls tell me....thanx for ur help... :)

-----------------------------------
santabruzer
Sat Jan 10, 2004 1:37 pm


-----------------------------------
use "mousewhere".. it'll return you where the mouse is.. and if the button is pressed.. so that
var x, y, button : int
mousewhere (x, y, button)

Then you can make an if statement, that 

if button = 1 then
*code here*
end if

It's pretty straight forward.. but if you get confused, look in help!  :)

-----------------------------------
CITC
Sat Jan 10, 2004 1:38 pm


-----------------------------------
you need to use the Mouse.Where command and make if statements


var x,y,btn : int
Mouse.Where (x,y,btn)
if x > ## and x < ## and y > ## and y < ## and btn = 1 then
%do whatever you want here
end if


or you can do the cheap way out and do:

if whatdotcolour (x,y) = ## then


-----------------------------------
CITC
Sat Jan 10, 2004 1:39 pm


-----------------------------------
lol 1 minute before me :P

-----------------------------------
santabruzer
Sat Jan 10, 2004 1:39 pm


-----------------------------------
ha ha.. the second time it happened to me.. and it doesn't matter which Mouse Where you use.. they are both identical...

-----------------------------------
air_force91
Sat Jan 10, 2004 1:41 pm


-----------------------------------
do u know how to make a picture appear as the background of the execution window? coz my page seems too simple...

-----------------------------------
santabruzer
Sat Jan 10, 2004 1:50 pm


-----------------------------------
i would think
picUnderMerge   This draws the picture, but only where the background color was displayed underneath it. The effect of this is to make the picture appear to be displayed behind the background. 

-----------------------------------
air_force91
Sun Jan 11, 2004 11:18 am

this is what ive donw
-----------------------------------
ive inserted ur code but it still doesn't work...

setscreen ("graphics:800;350")

colourback (red)
cls

var fontID : int := Font.New ("Franklin Gothic Medium:16:bold")
Font.Draw ("Welcome To", 300, 300, fontID, blue)
Font.Draw ("...", 350, 270, fontID, yellow)
%3D effect for "The Ultimate MB!!"

var size : int
var text1 : string
size := 40
var text := "The Ultimate MB!!"

var afontID : array 1 .. size of int

for i : size div 2 .. size
    afontID (i) := Font.New ("Tahoma:" + intstr (i))

end for


procedure Text3D (text : string)

    for t : 1 .. length (text)

        for i : size div 2 .. size
            Font.Draw (text (t), t * size, 170, afontID (i), 20 + floor
                (i / size * 10))

        end for
    end for

end Text3D

Text3D (text)

%ball animation

%Import computer picture

var comppic : int := Pic.FileNew ("comp2.bmp")
Pic.Draw (comppic, 20 div 2, 20 div 2, picMerge)

%"enter any key"

var bfontID : int := Font.New ("Arial:10:bold")
Font.Draw ("Press any key to continue...", 597, 25, bfontID, blue)

loop
    exit when hasch
end loop
cls


can u tell me y the click's not working? i can't figure it out...thanx.

-----------------------------------
santabruzer
Sun Jan 11, 2004 11:23 am


-----------------------------------
here.. try this:
setscreen ("graphics:800;350") 

colourback (red) 
cls 

var fontID : int := Font.New ("Franklin Gothic Medium:16:bold") 
Font.Draw ("Welcome To", 300, 300, fontID, blue) 
Font.Draw ("...", 350, 270, fontID, yellow) 
%3D effect for "The Ultimate MB!!" 

var size : int 
var text1 : string 
size := 40 
var text := "The Ultimate MB!!" 

var afontID : array 1 .. size of int 

for i : size div 2 .. size 
    afontID (i) := Font.New ("Tahoma:" + intstr (i)) 

end for 


procedure Text3D (text : string) 

    for t : 1 .. length (text) 

        for i : size div 2 .. size 
            Font.Draw (text (t), t * size, 170, afontID (i), 20 + floor 
                (i / size * 10)) 

        end for 
    end for 

end Text3D 

%Import computer picture 

var comppic : int := Pic.FileNew ("comp2.bmp") 
Pic.Draw (comppic, 20 div 2, 20 div 2, picMerge) 

Text3D (text) 

%ball animation 


%"enter any key" 

var bfontID : int := Font.New ("Arial:10:bold") 
Font.Draw ("Press any key to continue...", 597, 25, bfontID, blue) 

loop 
    exit when hasch 
end loop 
cls 


-----------------------------------
air_force91
Sun Jan 11, 2004 12:16 pm


-----------------------------------
oppsss sorry...im getting soo stressed out from all the exams and stuff...im sorry...i copied the wrong page of code...now this is the page where i inserted the mouseclick function...and it doesn't work....

setscreen ("graphics:800;350")

colourback (3)
cls


%2nd page

var size : int
var text1 : string
size := 15
var text := "The Ultimate MB!!"

var afontID : array 1 .. size of int

for i : size div 2 .. size
    afontID (i) := Font.New ("Tahoma:" + intstr (i))

end for


procedure Text3D (text : string)

    for t : 1 .. length (text)

        for i : size div 2 .. size
            Font.Draw (text (t), t * size, 315, afontID (i), 20 + floor
                (i / size * 10))

        end for
    end for

end Text3D

Text3D (text)

%%Import computer picture

var comppic : int := Pic.FileNew ("comp3.bmp")
Pic.Draw (comppic, 50 div 2, 20 div 2, 0)


%%%%%%%%%%%%%%%%%%%%%%buttons

%3rd button

Draw.FillBox (550, 40, 667, 90, 5)

var bfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Exit", 590, 60, bfontID, black)

%2nd button

Draw.FillBox (550, 140, 667, 190, 5)

var cfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Start Game", 562, 160, cfontID, black)

%1st button

Draw.FillBox (550, 240, 667, 290, 5)

var dfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Instructions", 562, 260, dfontID, black)

%%%mouse detect--*click*
 
var x,y,btn : int 
Mouse.Where (x,y,btn) 

if x >= 550 and x = 240 and y = 550 and x = 240 and y 