Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 buttons and clicks
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
air_force91




PostPosted: Sat Jan 10, 2004 1:27 pm   Post subject: 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:

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... Smile
Sponsor
Sponsor
Sponsor
sponsor
santabruzer




PostPosted: Sat Jan 10, 2004 1:37 pm   Post subject: (No subject)

use "mousewhere".. it'll return you where the mouse is.. and if the button is pressed.. so that
code:
var x, y, button : int
mousewhere (x, y, button)


Then you can make an if statement, that

code:
if button = 1 then
*code here*
end if


It's pretty straight forward.. but if you get confused, look in help! Smile
CITC




PostPosted: Sat Jan 10, 2004 1:38 pm   Post subject: (No subject)

you need to use the Mouse.Where command and make if statements

code:

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:
code:

if whatdotcolour (x,y) = ## then
CITC




PostPosted: Sat Jan 10, 2004 1:39 pm   Post subject: (No subject)

lol 1 minute before me Razz
santabruzer




PostPosted: Sat Jan 10, 2004 1:39 pm   Post subject: (No subject)

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




PostPosted: Sat Jan 10, 2004 1:41 pm   Post subject: (No subject)

do u know how to make a picture appear as the background of the execution window? coz my page seems too simple...
santabruzer




PostPosted: Sat Jan 10, 2004 1:50 pm   Post subject: (No subject)

i would think
Quote:
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




PostPosted: Sun Jan 11, 2004 11:18 am   Post subject: this is what ive donw

ive inserted ur code but it still doesn't work...

code:
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.
Sponsor
Sponsor
Sponsor
sponsor
santabruzer




PostPosted: Sun Jan 11, 2004 11:23 am   Post subject: (No subject)

here.. try this:
code:
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




PostPosted: Sun Jan 11, 2004 12:16 pm   Post subject: (No subject)

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....

code:
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 <= 667 and y >= 240 and y <= 290 and btn = 1 then
cls
end if
air_force91




PostPosted: Sun Jan 11, 2004 12:18 pm   Post subject: (No subject)

and u know the "picUnderMerge"...well I can't view my pic when i use the command...i want my picture to be set as the background of the screen but using this...i can;t see the pic at all...
santabruzer




PostPosted: Sun Jan 11, 2004 12:20 pm   Post subject: (No subject)

here.. post the pic.. and the Turing File..
air_force91




PostPosted: Sun Jan 11, 2004 12:32 pm   Post subject: (No subject)

[img]www.extendinc.com/ computer.jpg[/img]

that's the image i want as the background...and attached is the main page...thanx sooooo much...



The Ultimate MB!!.t
 Description:

Download
 Filename:  The Ultimate MB!!.t
 Filesize:  1.04 KB
 Downloaded:  284 Time(s)

santabruzer




PostPosted: Sun Jan 11, 2004 2:59 pm   Post subject: (No subject)

Here it is (the pic is attached):
code:
setscreen ("graphics:800;350,nocursor")

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 := 40
var text1 : string
var text := "The Ultimate MB!!"
var ch : string (1)

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% You have to insert the picture before the text, so that                   %
%  the text will overlap the picture                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Import computer picture
var comppic : int := Pic.FileNew ("computerback.jpg")
Pic.Draw (comppic, maxx div 2 - (Pic.Width (comppic) div 2), maxy div 2 - Pic.Height (comppic) div 2, picMerge)

%ball animation
Text3D (text)


%"enter any key"
var bfontID : int := Font.New ("Arial:10:bold")
Font.Draw ("Press any key to continue...", 597, 25, bfontID, blue)
getch (ch)



computerback.jpg
 Description:
Background Type Picture
 Filesize:  9.04 KB
 Viewed:  6544 Time(s)

computerback.jpg


CITC




PostPosted: Sun Jan 11, 2004 6:12 pm   Post subject: (No subject)

just from looking quickly at the code (I didn't download the files either)

you have no loop around your mousewhere bit. Therefore there is only a split-second when if you click the mouse it'll do anything.

code:
%%%mouse detect--*click*
loop 
var x,y,btn : int
Mouse.Where (x,y,btn)

if x >= 550 and x <= 667 and y >= 240 and y <= 290 and btn = 1 then
cls
end if
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: