Skip to main content
GameDev.net gamedev.net
🔒 Locked

input from a mouse

Started by quadrafuzz Aug 17, 2001 at 6:43 PM 1 replies 400+ views
Original Post
quadrafuzz
quadrafuzz
I''m trying to use directinput to have little bitmaps disappear when they are clicked on. How do I test the entire bitmap rectangle to see whether it should disappear or not? I have a struct with the x and y positions stored in it and right now I''m testing whether the x and y coordinates match those of the mouse when the left mouse button is clicked and if they match the bitmap disappears, however, this isn''t working. How do I get the bitmap to disappear when you click anywhere within the bitmap rectangle while the left mouse button is clicked? Any help is appreciated. quad
fredjordans
fredjordans
Well, assuming that you know the height and width of your bitmap, you can just use an if then statement as follows:

if mouse.button[0]
{
if mouse.x > bitmap.x And mouse.x < mouse.x+width And mouse.y > bitmap.y And mouse.y < mouse.y+height Then DeleteBitmap
}

where 0 represents the left mouse button.

I assume you know the syntax for If Then statements... I also assume that you understand DirectINput and how to check for x, y, and left click. if not, let me know.
-eat me!-but i''m not a cannibal!
QBRADQ
QBRADQ
Also note that you must overwrite the section on the displayed surface with your background color or image, other wise it will still be displayed.
Tell him about the twinky...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.