Can _MOUSEMOVEMENTX & Y be used for something like this? - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Can _MOUSEMOVEMENTX & Y be used for something like this? (/showthread.php?tid=2101) |
Can _MOUSEMOVEMENTX & Y be used for something like this? - Dav - 10-15-2023 I'm trying to grasp using_MOUSEMOVEMENTX & Y in a program, not sure I fully understand these two functions yet. I have run the wiki examples, but I'm not seeing how they could be used for something like below. Could those functions be used to easier compute mouse movement for like grabing an object and move it only for as much as the mouse has moved since clicking on it? Here's some code I was playing with for testing. Could something like this be streamlined with _MOUSEMOVEMENTX & Y instead of using another DO/LOOP to calculate mouse movement? - Dav Code: (Select All)
RE: Can _MOUSEMOVEMENTX & Y be used for something like this? - SMcNeill - 10-15-2023 I think a lot of folks misunderstand what MouseMovementX and MouseMovementY are for. First thing to note: They're NOT for tracking your mouse's absolute position on the screen. There's _MouseX and _MouseY for that. So what are they for?? Let's move our thinking from QB64PE out to just playing some game. Now, in this game, you're in a spaceship flying through outer space. To control your ship, it's set up to use a simple scroll ball as the navigation tool. Scroll that ball right, and the ship turns right. Scroll that ball left, and the ship turns left. Scroll that ball up, and the ship flys down. (The arse end goes up, the nose goes down.) Scroll that ball down, and the ship flys up. (The arse end goes down, the nose goes up.) Now, tracking mouse position in this situation is just foolish. You scroll right.... right... right.... right.... Hit the edge of the screen with the mouse, and BOOM!! Your ship can no longer rotate to the right in outer space!! See the problem with trying to use _MouseX in this situation? You can turn right and go around in circles till the end of time. Your mouse cursor, however, is going to stop at the edge of your screen. So, how to track this "ball rotated right" event?? _MouseMovementX. Even if the mouse is at the right edge of the screen, you can scroll that mouseball on your desk endlessly to the right. It won't move the mouse pointer -- it's already at the limit -- but _MouseMovementX will record that rotation and report it to you. MouseMovementX simply tells you if your mouseball has rotated left or right. MouseMovementY tells you if that mouseball has rotated up or down. It has nothing to do with screen coordinates. Just mouse wheel scrolling itself. RE: Can _MOUSEMOVEMENTX & Y be used for something like this? - James D Jarvis - 10-15-2023 Does this do what you want? Code: (Select All)
RE: Can _MOUSEMOVEMENTX & Y be used for something like this? - Dav - 10-15-2023 Ahh, I think I get it now. Yeah, I misunderstood these alright. Thanks for the explanation! EDIT: Sorry, James, I didn't notice your post before I replied. Well, yeah, but the original worked too, I just wondered if I could bypass the 2nd mousey DO/LOOP and drawing, by just using _MOUSEMOVEMENT positions instead, but thanks for trying to help me out, I appreciate it. - Dav RE: Can _MOUSEMOVEMENTX & Y be used for something like this? - SMcNeill - 10-15-2023 Try this out @Dav : https://qb64phoenix.com/forum/showthread.php?tid=2102 |