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

Username:   Password: 
 RegisterRegister   
 Drawing Game [Done button difficulties!]
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
penny2199




PostPosted: Tue Nov 18, 2014 10:43 am   Post subject: Drawing Game [Done button difficulties!]

Im trying to make a drawing game and so far I can't get my 'done' button to work. I'm not certain how to get the area where the user clicks it to clear the screen and have it restart. I'm also facing difficulties of having the user still be able to draw, but when he/she pulls their mouse to the 'done' button it should change to a regular mouse icon and have it be clicked to clear the screen.


Turing:


put "Done drawing?"

var picID : int
picID := Pic.FileNew ("donebutton.bmp")
Pic.Draw (picID, 10, 80, picCopy)

var x, y, button : int
loop
    Mouse.Where (x, y, button)
    locate (1, 1)

   
    if button = 1 then
        drawfilloval (x, y, 10, 10, red)

    end if

end loop


Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Nov 18, 2014 11:34 am   Post subject: RE:Drawing Game [Done button difficulties!]

First thing you need to do is figure out when the mouse is on the button. You can write a function to do that.

code:
func button_mouseover (mousex : int, mousey : int) : bool
%Figure out if the mouse is over the button
end button_mouseover


Fill that function in, toss it in your loop, and now you can detect when the mouse is over the button. From there, it's easy to decide a few things:

-if the mouse is over the button, don't draw ovals.
-if the mouse is over the button and the mousebutton is clicked, quit the loop/clear the screen/whatever you want to do there.

There are plenty of tutorials on making your own buttons. It's just a really simple collision detection between a point and a rectangle.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: