Posted: 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:
code:
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
Sponsor Sponsor
beedub
Posted: Mon May 12, 2003 8:36 pm Post subject: (No 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..
Dan
Posted: Mon May 12, 2003 8:58 pm Post subject: (No 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.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
beedub
Posted: Mon May 12, 2003 9:19 pm Post subject: (No subject)
i know this is kinda sad.. but.. i am so confused... ... looks like im not cut out for this sheit
void
Posted: Mon May 12, 2003 9:19 pm Post subject: (No subject)
jeeze dan...he clearly stated he was n00b...that means NEWbe....the NEW meaning he NEW to the language...ya...im just kidding man...i was bored as hell...and i came across this..
SUGGESTION:
if your just doing a program that has nothing in the background but this button...like...if 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 n00b...im gonna post the syntax...dont just copy and be satisfied...im doing this coz personaly i learned best from examples when i started programming...so 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 see...im am very against the copying of codes..but posting them helps you learn)
code:
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
loop
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....
beedub
Posted: Mon May 12, 2003 9:20 pm Post subject: (No subject)
TY>>>
Tony
Posted: Mon May 12, 2003 9:22 pm Post subject: (No 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
Posted: Mon May 12, 2003 9:25 pm Post subject: (No 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
Sponsor Sponsor
beedub
Posted: Mon May 12, 2003 9:28 pm Post subject: (No 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...
Tony
Posted: Mon May 12, 2003 9:32 pm Post subject: (No 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
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.
Posted: Mon May 12, 2003 9:41 pm Post subject: (No subject)
omg thats it... i am such a stupid kid... there we go
beedub
Posted: Mon May 12, 2003 9:49 pm Post subject: (No subject)
it works perfectly now....
Homer_simpson
Posted: Mon May 12, 2003 9:57 pm Post subject: (No subject)
these 2 functions may help you...
code:
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
loop
if circlemouseover (400, 100, 100) then
drawfilloval (400, 100, 100, 100, 12)
else
drawfilloval (400, 100, 100, 100, 9)
end if
if rectanglemouseover (50, 50, 200, 200) then
drawfillbox (0, 0, 200, 200, 12)
else
drawfillbox (0, 0, 200, 200, 9)