MouseMovement Demo - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Prolific Programmers (https://qb64phoenix.com/forum/forumdisplay.php?fid=26) +---- Forum: SMcNeill (https://qb64phoenix.com/forum/forumdisplay.php?fid=29) +---- Thread: MouseMovement Demo (/showthread.php?tid=2102) |
MouseMovement Demo - SMcNeill - 10-15-2023 Code: (Select All)
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. I hope the demo above helps to highlight what these commands are actually used for, for us. |