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

Username:   Password: 
 RegisterRegister   
 MouseWhere
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mtk786




PostPosted: Wed Mar 03, 2004 6:46 pm   Post subject: MouseWhere

Hi, im a beginner programmer and im just wondering how i would make progam which would allow the user

to go click on a circle and then it displays text...for example i have a circle and when i click on it it is suppose to give me text on a new screen

so neone plz msg me
tnks alot
u guyz are the best Surprised
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: Wed Mar 03, 2004 6:50 pm   Post subject: (No subject)

well, you probably know about mousewhere, and if you don't look at reference because then you could learn on your own and probably learn some other things too. this is more of problem solving, i don't know, you could test if you're in the circle by "making" and imaginary box around and checking the coordinates. you can do that by yourself, its easy.

another way:
make the circle a unique colour and then use whatdotcolour and dodge will love you forever. just do:

loop
mousewhere(mousex, mousey, button)
if whatdotcolour(mousex, mousey)={yourcolour}
the print text on screen
end if
end loop

you should try it yourself though, its really easy.
Thuged_Out_G




PostPosted: Wed Mar 03, 2004 9:31 pm   Post subject: (No subject)

disregard jonos example, that will have nothing to do with clicking, just where you put your cursor.

code:

var x, y, button : int
var count := 0

Draw.FillOval (150, 150, 100, 100, black)

loop
    delay (100)
    if count = 9 then
        cls
        Draw.FillOval (150, 150, 100, 100, black)
        count := 0
    end if
    loop
        Mouse.Where (x, y, button)
        if button = 1 and whatdotcolor (x, y) = black then
            count += 1
            put "You clicked in the circle!"
            exit
        end if
    end loop
end loop


there, that will put to the screen whenever you click in the circle, and it will never put text over the circle...because once you do that, it will erase part of the circle...do it enough and you have no circle left to click on lol
jonos




PostPosted: Wed Mar 03, 2004 9:33 pm   Post subject: (No subject)

you're not supposed to give him the code, your supposed to try and help him figure it out for himself. its not that hard to do, and he should learn to try it for himself. anyways nice code.
recneps




PostPosted: Fri Mar 05, 2004 3:56 pm   Post subject: (No subject)

or, if you're not doing anything else in the program except waiting for a click, you can use buttonwait (good for stopping the program and wait for click before going on with what the click told the program) Its used in same way, but you specify the type of click
like up, down, updown, and the button type , left, right, middle.
and for it to be a CIRCLE button, then you should use a circular way of checking, rather than a box. You could use
code:
if Math.Distance (mousex,mousey,circlex,circley) +radius <0 then
%Code for what happens when click button.
end if
jonos




PostPosted: Fri Mar 05, 2004 4:03 pm   Post subject: (No subject)

i don't think he wants to have to press the button when he wants something to appear.
recneps




PostPosted: Fri Mar 05, 2004 4:14 pm   Post subject: (No subject)

Wait, on my thing for circle, i believe it should be

if Math.Distance(mousex,mousey,circlex,circley) <radius then

But i believe it would work both ways. Wink
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 1  [ 7 Posts ]
Jump to:   


Style:  
Search: