Graphics.h how to check if the left mouse button is held down?
11 replies, posted
Hey.
So the graphics.h libaray is terribly documented and i couldnt figure out how to check if the left mouse button is pressed.
Can someone help me with this?
im using the librarys from:
[1]: [url]http://winbgim.codecutter.org/[/url]
There's a question thread for questions just like this: [URL]https://facepunch.com/showthread.php?t=1446371[/URL]
Either way, it seems to have a function called [URL="http://www.cs.colorado.edu/~main/cs1300/doc/bgi/getmouseclick.html"]getmouseclick[/URL]. Try that.
[QUOTE=Asgard;50027321]There's a question thread for questions just like this: [URL]https://facepunch.com/showthread.php?t=1446371[/URL]
Either way, it seems to have a function called [URL="http://www.cs.colorado.edu/~main/cs1300/doc/bgi/getmouseclick.html"]getmouseclick[/URL]. Try that.[/QUOTE]
I tried it but it doesnt work. It just returns the coordinates. I just need to check if the mouse has been pressed.
[quote]
After calling getmouseclick, for a particular kind of event, the ismouseclick will return false for that kind of event until another such event occurs.
[/quote]
So only do a getmouseclick if ismouseclick returns true
[QUOTE=MoustacheSpy;50027340]I tried it but it doesnt work. It just returns the coordinates. I just need to check if the mouse has been pressed.[/QUOTE]
[quote] This function sets x and y to the pixel coordinates of an unprocessed event of the specified kind. [B]If there is no such event[/B], then the function sets both [B][U][I]x and y to -1[/I][/U][/B]. [/quote]
Or what he said, by using "ismouseclick" which returns a boolean
-snip-
[QUOTE=Karmah;50027375]Or what he said, by using "ismouseclick" which returns a boolean[/QUOTE]
Okay. I tried that with the correct mode for only the left mouse button. it works but it stays true forever, meaning that the thing i wanted to trigger with it will continioue to happen even after the player released the button. What to do now?
[QUOTE=MoustacheSpy;50027550]Okay. I tried that with the correct mode for only the left mouse button. it works but it stays true forever, meaning that the thing i wanted to trigger with it will continioue to happen even after the player released the button. What to do now?[/QUOTE]
Next step is working on your reading comprehension
[quote]After calling getmouseclick, for a particular kind of event, the ismouseclick will return false for that kind of event until another such event occurs.[/quote]
[code]
if( ismouseclick( WM_LBUTTONUP ) ) {
getmouseclick( WM_LBUTTONUP, x, y );
}
[/code]
The 'getmouseclick' call resets the ismouseclick boolean
[QUOTE=Asgard;50027603]Next step is working on your reading comprehension
[code]
if( ismouseclick( WM_LBUTTONUP ) ) {
getmouseclick( WM_LBUTTONUP, x, y );
}
[/code]
The 'getmouseclick' call resets the ismouseclick boolean[/QUOTE]
Okay thank you. Im gonna try that right now. And also my english isnt bad im just too lazy to read over it again :/
[QUOTE=MoustacheSpy;50027627]Okay thank you. Im gonna try that right now. And also my english isnt bad im just too lazy to read over it again :/[/QUOTE]
Get used to having to read documentation. You didn't write the library, so look up what the functions do before hand...
[QUOTE=Karmah;50027644]Get used to having to read documentation. You didn't write the library, so look up what the functions do before hand...[/QUOTE]
No i thought he meant because i made alot of mistakes, not that i didnt read over the Documentation. It wasnt very clear. There werent referring to ismouseclick not even once. Maybe i was reading the wrong doc.
[QUOTE=MoustacheSpy;50027697]No i thought he meant because i made alot of mistakes, not that i didnt read over the Documentation. It wasnt very clear. There werent referring to ismouseclick not even once. Maybe i was reading the wrong doc.[/QUOTE]
I quoted the part that said you should call getmouseclick to reset ismouseclicked. That's what I meant with reading comprehension.
Sorry, you need to Log In to post a reply to this thread.