Various code questions
#5
#3 -- WHILE _MOUSEINPUT: WEND

Our mouse information is stored in a array that updates a couple of bazillion times per second. (Maybe not that fast, but it certainly seems like it sometimes!) As we normally don't run our program loops at this insane rate, we end up using the above to clear the mouse input buffer until we just deal with the most relevant information for us.

For example, scroll the mouse to the right for 1 second. You might have a whole series of movement updates:

mouseX at 123
mouseX at 123.1
mouseX at 123.3
mouseX at 123.4
mouseX at 123.6
mouseX at 123.8
mouseX at 124
mouseX at 124.1
mouseX at 124.3
mouseX at 124.4

Now, if you've got a _LIMIT 1 in your program, you're only going to run your main loop one time per second. The above has 10 mouseX positions where it moved across the screen in that one second. Are you going to spend 10 seconds trying to process all of those events?? Or are you going to simply say, "Hey! Where the heck was the mouse when the program loop processed?"

While _mouseInput: Wend says to toss out the intermediate mouseX/Y positions and only deal with the current one. We don't need to know when it changed a half a pixel -- we just need to know where it was at when the main loop processed, and whether the user has hit the button or not since the last loop.
Reply


Messages In This Thread
Various code questions - by james2464 - 08-17-2022, 01:57 PM
RE: Various code questions - by mnrvovrfc - 08-17-2022, 02:09 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:09 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:13 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:21 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 02:30 PM
RE: Various code questions - by OldMoses - 08-17-2022, 04:55 PM
RE: Various code questions - by james2464 - 08-17-2022, 06:30 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 06:35 PM
RE: Various code questions - by james2464 - 08-17-2022, 06:43 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 06:53 PM
RE: Various code questions - by Kernelpanic - 08-17-2022, 08:32 PM
RE: Various code questions - by SMcNeill - 08-17-2022, 09:25 PM
RE: Various code questions - by Kernelpanic - 08-18-2022, 01:31 PM



Users browsing this thread: 3 Guest(s)