Computer Science Canada

Mouse Question

Author:  beedub [ Mon May 12, 2003 8:34 pm ]
Post subject:  Mouse Question

kkkk... here it is... i need some help with mouse action (when i press a certain image)..... here is the image that i need help with:
drawfilloval (260, 140, 40,20,113)
when it is pressed i need to to go to a clear screen... lol this isnt a project i am working on... my school doesnt even have turing.. im 12... apparently you dont start learning it till highschool...

MOD EDIT: Title has been changed. Do not make general topics. -Asok

Author:  beedub [ Mon May 12, 2003 8:36 pm ]
Post subject: 

also... sorry im not actually helping ne one... i need actually learn how to "ture"to be cable to help people... lol.. but when ever i make some n00bish games ill be sure to post it.. Embarassed

Author:  Dan [ Mon May 12, 2003 8:58 pm ]
Post subject: 

i am asuming you know the mouse codes...

basickly you do closion dection but with the mouse's quartents and the loaction of the image.

tutorial on colsion dection:

rember to look down for info on dection for difrent shaps and i think there is info on mouse closion dection.

also for mouse codes go here:

Author:  beedub [ Mon May 12, 2003 9:19 pm ]
Post subject: 

i know this is kinda sad.. but.. i am so confused... Sad... looks like im not cut out for this sheit

Author:  void [ Mon May 12, 2003 9:19 pm ]
Post subject: 

jeeze dan...he clearly stated he was n00b...that means NEWbe....the NEW meaning he NEW to the just kidding man...i was bored as hell...and i came across this..
if your just doing a program that has nothing in the background but this the color of the button is not like the color of anything else that you have on the screen on the moment...then use whatdotcolor..of the location...since your a gonna post the syntax...dont just copy and be doing this coz personaly i learned best from examples when i started im assuming you might be like me...if you can learn how to use the code without copying...then ur better off because you can manipulate it in other programs u make...(as you can am very against the copying of codes..but posting them helps you learn)

var x, y, button : int
%%X is the x co-ordinate of the mouse, y being the y co-ordinate, and button is a variable telling you if the button is clicked or not
drawfilloval (260, 140, 40, 20, 113)
%%draw the circle...blah blah
    Mouse.Where (x, y, button)
    %%calls the mouse where which finds out WHERE THE MOUSE IS.....(its done in a loop because the mouse is constantly moving
    if whatdotcolor (x, y) = 114 and button = 1 then
        %%if the color under the pointer is equal to that of the circle and the button is clicked then
        cls %%clear the screen
        exit%%exit the loop
    end if%%end the if statement
end loop%%end the loop
%%sorry for the over comenting....

Author:  beedub [ Mon May 12, 2003 9:20 pm ]
Post subject: 


Author:  Tony [ Mon May 12, 2003 9:22 pm ]
Post subject: 

yeah... dan often scares people with his replies... but he does pay the bills and edits some PHP so I think we should let him stay an admin for a little while longer Wink

Author:  beedub [ Mon May 12, 2003 9:25 pm ]
Post subject: 

i agree.. lol just trying to get bits... even tho i dont really know what they do... cept they give you a glow on ur name... hopefully ill get that soon...anyways srry...and ty dan for being a good admin... and payer of bills Wink

Author:  beedub [ Mon May 12, 2003 9:28 pm ]
Post subject: 

omg... i am so srry... for taking up this whole post.. but.. i need some help with the collision detection part of it... if i want the circle (posted earlier).. to be pressed any where on it.. how would i fit that into the code that void posted earlier...

Author:  Tony [ Mon May 12, 2003 9:32 pm ]
Post subject: 

well void's code checks for the color of the circle, so technically you can click a same colored square anywhere else on the screen for it to work Confused

So your circle can be places anywhere on the screen. (Gotta be unique color though).

If you want a mathimatical aproach, you chould check out circle collision detection ( in tutorials). You basically just see how far away you clicked from the center of the circle.

Author:  beedub [ Mon May 12, 2003 9:38 pm ]
Post subject: 

thats what i have been trying to do... but i just cant seem to be able to... make it go to a differetn screen when it is pressed

Author:  Tony [ Mon May 12, 2003 9:40 pm ]
Post subject: 

thats cuz void's code is wrong. Buttom color is 113 but he's checking for 114 Confused

In the if statment, the color must be the same as of your button

Author:  beedub [ Mon May 12, 2003 9:41 pm ]
Post subject: 

omg thats it... i am such a stupid kid... there we go

Author:  beedub [ Mon May 12, 2003 9:49 pm ]
Post subject: 

it works perfectly now....

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

these 2 functions may help you...
function rectanglemouseover (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 rectanglemouseover

function circlemouseover (x1, y1, radius : int) : boolean
    var x2, y2, mouseb : int
    mousewhere (x2, y2, mouseb)
    if round (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** .5) < radius then
        result true
    end if
    result false
end circlemouseover

    if circlemouseover (400, 100, 100) then
        drawfilloval (400, 100, 100, 100, 12)
        drawfilloval (400, 100, 100, 100, 9)
    end if

    if rectanglemouseover (50, 50, 200, 200) then
        drawfillbox (0, 0, 200, 200, 12)
        drawfillbox (0, 0, 200, 200, 9)

    end if
    delay (10)
end loop

Author:  void [ Tue May 13, 2003 10:30 am ]
Post subject: 

yea...i dont think a twelve year old understands how the equation for finding radius unsing x and y works....also...i dont they have even learned simple y=mx+b stuff....if you do know how to do that....thats great hello....and oh sorry for having 114 as the color Confused ....eheheeehehe Embarassed should work fine now the way...what kind of game are you making?....or what is the point of your program

Author:  beedub [ Tue May 13, 2003 4:46 pm ]
Post subject: 

its ok... lo.l.. but ya i know most coding.. like x y rad and sheit like that... i also learned y+mx+b... but the thing i dont know all the function codes....and how to use em... and sometimes when you go to help on turing its not the exsact you wanted..

Author:  beedub [ Tue May 13, 2003 4:47 pm ]
Post subject: 

i might actuyally do a mouseover aswell.. i know how to do it... but i am doing so the user knows that it is picked..

Author:  void [ Tue May 13, 2003 6:07 pm ]
Post subject: 

yea... i never found tutorials that helpful either...i learn by examples....mouse over is really easy...make two pictures...and when you do that collision detection thing..go like this
if the parameters (x,y,x2,y2) are right then
replace the picture with this one
if the mouse is clicked then
end if
end if
you get?

Author:  beedub [ Tue May 13, 2003 9:56 pm ]
Post subject: 

okee dokee.... ya i just take the examples and change coordinates and stuff..