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

Username:   Password: 
 RegisterRegister   
 mouseover
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
beedub




PostPosted: Sat May 17, 2003 11:49 am   Post subject: mouseover

hey all my.. mouseover only works for the first button... why is this? here is the code...
code:


%menu.t

var font1, font2, font3, font4, line : int
font1 := Font.New ("courier:10")
font2 := Font.New ("courier:10:bold")

%function mouseover
var mousex, mousey, mouseb,mousex1, mousey1, mouseb1,mousex2, mousey2, mouseb2,mousex3, mousey3, mouseb3 : int
function mouseover (x, y, x1, y1, x2, y2 : int) : boolean
    if x >= x1 and x <= x2 then
        if y >= y1 and y <= y2 then
            result true
        end if
    end if
    result false
end mouseover
% Back part of screen

drawfillbox (0, 0, 640, 400, 23)

% Part Underneath
drawfillbox (20, 110, 640, 150, 22)
drawbox (20, 110, 640, 150, 21)
var text : string
text := "SHOOTOUT"
var fontID : array 1 .. 32 of int

for i : 32 div 2 .. 32
    fontID (i) := Font.New ("courier:" + intstr (i))
end for

procedure Text3D (text : string)

    for t : 1 .. length (text)

        for i : 32 div 2 .. 32
            Font.Draw (text (t), t * 75, 120, fontID (i), 20 + floor (i / 32 * 10))
        end for

    end for

end Text3D

Text3D (text)


% Back part of menu


drawfillbox (260, 215, 380, 330, grey)
drawbox (260, 215, 380, 330, black)
drawfillbox (290, 350, 350, 330, grey)
drawbox (290, 350, 350, 330, black)
Font.Draw ("Menu", 300, 335, font2, black)

loop

    mousewhere (mousex, mousey, mouseb)
    if mouseover (mousex, mousey, 270, 300, 370, 320) then

        drawfillbox (270, 300, 370, 320, grey)
        drawbox (270, 300, 370, 320, black)
        Font.Draw ("Play game", 280, 308, font1, black)
    else
        drawfillbox (270, 300, 370, 320, 27)
        drawbox (270, 300, 370, 320, black)
        Font.Draw ("Play game", 280, 308, font1, black)
    end if


    %rules button
mousewhere (mousex1, mousey1, mouseb1)
    if mouseover (mousex1, mousey1, 270, 295, 370, 275) then
    drawfillbox (270, 295, 370, 275, grey)
    drawbox (270, 295, 370, 275, black)
    Font.Draw ("RULES", 289, 280, font1, black)
else
drawfillbox (270, 295, 370, 275, 27)
    drawbox (270, 295, 370, 275, black)
    Font.Draw ("RULES", 289, 280, font1, black)
end if
    %HIgh scores button
    mousewhere (mousex2, mousey2, mouseb2)
    if mouseover (mousex2, mousey2, 270, 270, 370, 250) then

    drawfillbox (270, 270, 370, 250, grey)
    drawbox (270, 270, 370, 250, black)
    Font.Draw ("High Scores", 282, 255, font1, black)
    else
      drawfillbox (270, 270, 370, 250, 27)
    drawbox (270, 270, 370, 250, black)
    Font.Draw ("High Scores", 282, 255, font1, black)
    end if
   

    %HIgh scores button
       mousewhere (mousex3, mousey3, mouseb3)
    if mouseover (mousex3, mousey3, 270, 245, 370, 225) then

    drawfillbox (270, 245, 370, 225, grey)
    drawbox (270, 245, 370, 225, black)
    Font.Draw ("EXIT", 290, 230, font1, black)
else
drawfillbox (270, 245, 370, 225, 27)
    drawbox (270, 245, 370, 225, black)
    Font.Draw ("EXIT", 290, 230, font1, black)
end if

end loop

also is there ne code to get rid of the detection lines?? (the little lines moving up and downt he buttons)
Sponsor
Sponsor
Sponsor
sponsor
nate




PostPosted: Sat May 17, 2003 3:23 pm   Post subject: View.Update

1 thing which would spare anyone who is playing that games eyes would be to use (these are the so called detection lines! (but they actually aren't))

View.Set ("offscreenonly") put this right before you loop

then put right before the end loop

View.Update

as for not workin for any of the other boxes i am 2 lazy to figure it out

-Nate
Homer_simpson




PostPosted: Sat May 17, 2003 4:30 pm   Post subject: (No subject)

the mouse over function needed alittle upgrade...
code:
%menu.t

var font1, font2, font3, font4, line : int
font1 := Font.New ("courier:10")
font2 := Font.New ("courier:10:bold")

%function mouseover
var mousex, mousey, mouseb, mousex1, mousey1, mouseb1, mousex2, mousey2, mouseb2, mousex3, mousey3, mouseb3 : int
function mouseover (x1, y1, x2, y2 : int) : boolean
    var x, y, b : int
    mousewhere (x, y, b)
    if (x >= x1 and x <= x2) or (x >= x2 and x <= x1) then
        if (y >= y1 and y <= y2) or (y >= y2 and y <= y1) then
            result true
        end if
    end if
    result false
end mouseover
% Back part of screen

drawfillbox (0, 0, 640, 400, 23)

% Part Underneath
drawfillbox (20, 110, 640, 150, 22)
drawbox (20, 110, 640, 150, 21)
var text : string
text := "SHOOTOUT"
var fontID : array 1 .. 32 of int

for i : 32 div 2 .. 32
    fontID (i) := Font.New ("courier:" + intstr (i))
end for

procedure Text3D (text : string)

    for t : 1 .. length (text)

        for i : 32 div 2 .. 32
            Font.Draw (text (t), t * 75, 120, fontID (i), 20 + floor (i / 32 * 10))
        end for

    end for

end Text3D

Text3D (text)


% Back part of menu


drawfillbox (260, 215, 380, 330, grey)
drawbox (260, 215, 380, 330, black)
drawfillbox (290, 350, 350, 330, grey)
drawbox (290, 350, 350, 330, black)
Font.Draw ("Menu", 300, 335, font2, black)

loop
    if mouseover ( 270, 300, 370, 320) then
        drawfillbox (270, 300, 370, 320, grey)
        drawbox (270, 300, 370, 320, black)
        Font.Draw ("Play game", 280, 308, font1, black)
    else
        drawfillbox (270, 300, 370, 320, 27)
        drawbox (270, 300, 370, 320, black)
        Font.Draw ("Play game", 280, 308, font1, black)
    end if
    if mouseover (270, 295, 370, 275) then
        drawfillbox (270, 295, 370, 275, grey)
        drawbox (270, 295, 370, 275, black)
        Font.Draw ("RULES", 289, 280, font1, black)
    else
        drawfillbox (270, 295, 370, 275, 27)
        drawbox (270, 295, 370, 275, black)
        Font.Draw ("RULES", 289, 280, font1, black)
    end if
    if mouseover (270, 270, 370, 250) then

        drawfillbox (270, 270, 370, 250, grey)
        drawbox (270, 270, 370, 250, black)
        Font.Draw ("High Scores", 282, 255, font1, black)
    else
        drawfillbox (270, 270, 370, 250, 27)
        drawbox (270, 270, 370, 250, black)
        Font.Draw ("High Scores", 282, 255, font1, black)
    end if
    if mouseover (270, 245, 370, 225) then

        drawfillbox (270, 245, 370, 225, grey)
        drawbox (270, 245, 370, 225, black)
        Font.Draw ("EXIT", 290, 230, font1, black)
    else
        drawfillbox (270, 245, 370, 225, 27)
        drawbox (270, 245, 370, 225, black)
        Font.Draw ("EXIT", 290, 230, font1, black)
    end if

end loop
Homer_simpson




PostPosted: Sat May 17, 2003 4:32 pm   Post subject: (No subject)

add this to the beggining of the program
code:
View.Set("offscreenonly")

and add this before end loop
code:
   View.Update
   delay(5)
beedub




PostPosted: Sat May 17, 2003 6:46 pm   Post subject: (No subject)

ty now it looks perfect..
beedub




PostPosted: Sat May 17, 2003 7:36 pm   Post subject: (No subject)

one other thing... if i wanted to make them as buttons what would i do... whatdotcolor... mouse.where??I only ask this cuz when it changes color i dont really know what to do..
Tony




PostPosted: Sat May 17, 2003 7:59 pm   Post subject: (No subject)

you shouldn't use what dot color, because that way you'd have to make all your objects different color Confused

just stick to math instead Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
beedub




PostPosted: Sat May 17, 2003 9:40 pm   Post subject: (No subject)

thats my porblem...since i am so young i havent been able to learn difficult math..the only way i can do it is with code.. or get some1 to help me with it... that is why i am here Wink
beedub




PostPosted: Sun May 18, 2003 3:27 pm   Post subject: (No subject)

ne ideas?
Tony




PostPosted: Sun May 18, 2003 4:49 pm   Post subject: (No subject)

i though you already got that mouseover procedure done?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
void




PostPosted: Sun May 18, 2003 7:39 pm   Post subject: (No subject)

can i suggest summin to u...USE GIU'S...ur menu isn't bad, but its kinda bad coz of the loop constantly refreshing itself...i'll c if i can make it betta...i'll post the finsished thingy soon...but yea...consider using a GUI..much easire...just create buttons and assigne procedures to them...
Tony




PostPosted: Sun May 18, 2003 10:39 pm   Post subject: (No subject)

but so does GUI.. run in a loop I mean...

its not VB's on event programming, its still linear loop.

you know that loop GUI.ProcessEvent end loop thingy?

well basically its a shorter way of sticking everything in a loop. Ofcourse once you start processing your GUI, you cant do much more...
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
beedub




PostPosted: Sun May 18, 2003 11:00 pm   Post subject: (No subject)

ya i know it... since this is my first actual good game.. i consider this like my tutorial game.. filled with flashing stuff...
void




PostPosted: Mon May 19, 2003 12:07 pm   Post subject: (No subject)

too lazy to actualy make a good one for u..well..if u dun wanna have a GUI event...then do this..have a "switch" variable for each button...and if the button has the mouse over it, then the "switch" is tripped and the color changes, but when the mouse moves from the vicinity then the switch is off and the button is redraw..1 time...this will stop the refresh thingy u'v got going.....tony...i dunno..GUI's look much better coz it doesnt "refresh" as often....but wateva...ur the boss... Rolling Eyes
beedub




PostPosted: Mon May 19, 2003 2:55 pm   Post subject: (No subject)

can u have mouseover GUIs?... and void what school you go to?
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  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: