05-01-2024, 11:42 PM
(04-25-2024, 01:40 AM)TerryRitchie Wrote:(04-25-2024, 01:06 AM)SMcNeill Wrote: Mouse your mouse events outside the update loop:LOL. Mouse your mouse events, cracked me up. I find myself doing these types of typos all the time.
But Steve is correct, the only thing that should be done within a mouse update loop is gathering scroll wheel events. Here's a demo of that:
Code: (Select All)SCREEN _NEWIMAGE(800, 600, 32)
radius = 50
DO
_LIMIT 60
CLS
LOCATE 2, 2: PRINT "_MOUSEHWEEL OUTSIDE THE UPDATE LOOP"
LOCATE 4, 2: PRINT "Use mouse wheel to change size of circle"
LOCATE 6, 2: PRINT "PRESS ANY KEY TO MOVE _MOUSEWHEEL INSIDE THE LOOP"
WHILE _MOUSEINPUT: WEND
radius = radius + _MOUSEWHEEL * 5
IF radius < 5 THEN radius = 5
CIRCLE (_MOUSEX, _MOUSEY), radius
_DISPLAY
LOOP UNTIL INKEY$ <> ""
DO
_LIMIT 60
CLS
LOCATE 2, 2: PRINT "_MOUSEHWEEL NOW INSIDE THE UPDATE LOOP"
LOCATE 4, 2: PRINT "Use mouse wheel to change size of circle"
LOCATE 6, 2: PRINT "PRESS ESC TO EXIT"
WHILE _MOUSEINPUT
radius = radius + _MOUSEWHEEL * 5
IF radius < 5 THEN radius = 5
WEND
CIRCLE (_MOUSEX, _MOUSEY), radius
_DISPLAY
LOOP UNTIL _KEYDOWN(27)
SYSTEM
So I have a question then about the mouse update loop and only putting MouseWheel events inside the While:Wend. I based one of my mouse routines on this, from HELP in the IDE under _MOUSEINPUT:
Code: (Select All)
DO WHILE _MOUSEINPUT 'mouse status changes only
x = _MOUSEX
y = _MOUSEY
IF x > 0 AND x < 640 AND y > 0 AND y < 480 THEN
IF _MOUSEBUTTON(2) THEN
PSET (x, y), 15
LOCATE 1, 1: PRINT x, y
END IF
END IF
LOOP
Is this not a proper approach? Is it okay to do this in a DO WHILE: LOOP, but not a WHILE:WEND? I mean, it works well...