Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Who wants to PLAY?
#11
(01-18-2025, 08:13 PM)bplus Wrote: Hello @dbox

I am testing the new Play demo with new Save and Load (very nice!) and notice a slight problem getting those mouse clicks caught!

maybe this requires, once again, another application of a _limit or a pause to get clear of a click.
see if this works better for you:
Code: (Select All)
Sub domousestuff
    Dim x, y
    While _MouseInput: Wend  ' there we've polled the mouse we don't need to remain inside the loop unless we need mouse wheel
    If _MouseButton(1) Then
        _delay .25 ' wait for user to release button
        x = Fix(_MouseX \ Fix(maxx \ 16))
        y = Fix(_MouseY \ Fix(maxy \ 16))
        grid(x, y) = 1 - grid(x, y)
    End If
End Sub

I am not proud of _delay .25 a quick hacky way to pause for a bit to clear the mouse button but it is short and sweet because it gets the job done better IMO than the first mouse catcher routine.

Hey @bplus, I took your concept and changed it a bit to use a TIMER to limit the checks on the mouse input since DELAY blocks the rest of the program execution.  I updated the last post with this version:
Code: (Select All)
SUB domousestuff
    DIM x, y
    WHILE _MOUSEINPUT: WEND
    IF _MOUSEBUTTON(1) AND TIMER - lastMouseEvent > .25 THEN
        x = FIX(_MOUSEX \ FIX(maxx \ 16))
        y = FIX(_MOUSEY \ FIX(maxy \ 16))
        grid(x, y) = 1 - grid(x, y)
        lastMouseEvent = TIMER
    END IF
END SUB

(01-18-2025, 08:42 PM)bplus Wrote: Well Music Grid needs its own folder under my QBJS folder since we are adding files.
...
nope! The text file saved is loadable but the txt file won't make it through editors from copy/paste.

You all will have to wait to here today's master piece. Big Grin

Actually you repeat something enough and almost anything starts to sound good, I think.

Yes, you'll have to upload it as file attachment to the post to share it with us.
Reply
#12
There was only a delay if Mousebutton is detected, not really that disruptive to the composer?

Now with Timer involved, you might run into the Midnight problem eg, last mouse was a second before midnight = big number next timer is the start of new day = small

st small - big = smaller!

OR make it a rule not to feed the Mogai and compose music after midnight! Big Grin
(but logically that means never do either)
b = b + ...
Reply
#13
One missed click at midnight is a risk I’m willing to take for smoother performance overall Smile
Reply
#14
Just for grins, here is another update with a midnight safe timer.  This demonstrates the fact that you can actually override default keywords in your program with your own implementation in QBJS.  (See line 125).

Reply
#15
This might do it too:
Abs(TIMER - lastMouseEvent) > .25
b = b + ...
Reply
#16
(01-19-2025, 06:49 AM)bplus Wrote: This might do it too:
Abs(TIMER - lastMouseEvent) > .25
I like that even better.
Reply
#17
My way of doing this would be:

Code: (Select All)
Sub domousestuff
    Dim x, y, mb
    STATIC OldMouse
    While _MouseInput: Wend  ' there we've polled the mouse we don't need to remain inside the loop unless we need mouse wheel
    mb = _MouseButton(1)
    If mb AND NOT OldMouse Then
        x = Fix(_MouseX \ Fix(maxx \ 16))
        y = Fix(_MouseY \ Fix(maxy \ 16))
        grid(x, y) = 1 - grid(x, y)
    End If
    OldMouse = mb
End Sub

Only count a mouseclick down if the mouse was up before clicking
Reply
#18
(Yesterday, 11:59 PM)SMcNeill Wrote: My way of doing this would be…

Only count a mouseclick down if the mouse was up before clicking

Yep, that’s a good option too.
Reply




Users browsing this thread: 11 Guest(s)