Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can _MOUSEMOVEMENTX & Y be used for something like this?
#1
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)

Screen _NewImage(800, 600, 32)

cx = 400: cy = 400

Do

    Cls , _RGB(32, 0, 0)

    Locate 1, 1: Print "Click on and drag curves to shape...";

    While _MouseInput: Wend

    'grabbed screen
    If _MouseButton(1) Then
        startmx = _MouseX: startmy = _MouseY

        '=====================================================
        'Can _MOUSEMOVEMENTX/Y be used instead of below?
        Do
            Cls , _RGB(32, 0, 0)
            While _MouseInput: Wend
            newcx = cx + (_MouseX - startmx)
            newcy = cy + (_MouseY - startmy)
            For c = -300 To 300 Step 20
                Curve 400, 100, 400, 500, newcx + c, newcy, _RGB(255, 0, 0)
            Next
            _Limit 30
            _Display
        Loop Until _MouseButton(1) = 0
        cx = newcx: cy = newcy
        '=====================================================

    End If

    For c = -300 To 300 Step 20
        Curve 400, 100, 400, 500, cx + c, cy, _RGB(255, 0, 0)
    Next

    _Limit 30
    _Display
Loop

Sub Curve (x1, y1, x2, y2, cx, cy, clr&)
    'Draws a curved line using a quadratic bezier curve formula
    'x1/y1 = start point
    'x2/y2 = end point
    'cx.cy = control point
    Do While t <= 1
        x = (1 - t) ^ 2 * x1 + 2 * (1 - t) * t * cx + t ^ 2 * x2
        y = (1 - t) ^ 2 * y1 + 2 * (1 - t) * t * cy + t ^ 2 * y2
        PSet (x, y), clr&
        t = t + .001
    Loop
End Sub

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
Can _MOUSEMOVEMENTX & Y be used for something like this? - by Dav - 10-15-2023, 11:17 PM



Users browsing this thread: 1 Guest(s)