Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom MouseMovement Example
#15
this is still not the most accurate solution. _mousemovement is proportional to windows mouse sensitivity. Moreover, the value of _limit can also influence it.
Let's make the real displacement independent of any FPS rate (_LIMIT). And be independent of Windows mouse sensitivity!

Change the value of _LIMIT ! the displacement will be unchanged. The speed of the circle will remain the same even if you turn off the mouse sensitivity in Windows.

Code: (Select All)
'windows mouse sensitivity and mouse positioning depending on _LIMIT value

limit = 100
mouse_speed = 1500


mon = _NewImage(800, 800 / _DesktopWidth * _DesktopHeight, 32)
Screen mon: _MouseHide: _FullScreen


Do: _Limit limit


    mx = 0: my = 0:

    While _MouseInput: mx = mx + _MouseMovementX: my = my + _MouseMovementY: Wend

    od = Sqr(mx * mx + my * my) 'original displacement

    ratio = 1 / od / limit * mouse_speed 'the amount of real displacement, which will only result from the _LIMIT value and the specified mouse speed

    fx = mx * ratio
    fy = my * ratio

    'circle position
    If Sgn(od) Then
        cx = cx + fx
        cy = cy + fy
    End If

    If cx < 0 Then cx = 0
    If cx > _Width - 1 Then cx = _Width - 1

    If cy < 0 Then cy = 0
    If cy > _Height - 1 Then cy = _Height - 1

    Circle (cx, cy), 40

    _Display: Cls


Loop


Reply


Messages In This Thread
Custom MouseMovement Example - by SMcNeill - 02-25-2024, 05:37 PM
RE: Custom MouseMovement Example - by NakedApe - 02-26-2024, 01:18 AM
RE: Custom MouseMovement Example - by SMcNeill - 02-26-2024, 03:29 AM
RE: Custom MouseMovement Example - by SMcNeill - 02-26-2024, 03:45 AM
RE: Custom MouseMovement Example - by NakedApe - 02-26-2024, 06:00 AM
RE: Custom MouseMovement Example - by NakedApe - 02-26-2024, 05:35 PM
RE: Custom MouseMovement Example - by SMcNeill - 02-27-2024, 07:15 AM
RE: Custom MouseMovement Example - by GareBear - 02-27-2024, 01:06 PM
RE: Custom MouseMovement Example - by SMcNeill - 02-27-2024, 01:28 PM
RE: Custom MouseMovement Example - by SMcNeill - 02-27-2024, 01:47 PM
RE: Custom MouseMovement Example - by NakedApe - 02-27-2024, 04:59 PM
RE: Custom MouseMovement Example - by SMcNeill - 02-27-2024, 05:06 PM
RE: Custom MouseMovement Example - by MasterGy - 02-27-2024, 05:18 PM
RE: Custom MouseMovement Example - by NakedApe - 02-27-2024, 07:17 PM
RE: Custom MouseMovement Example - by MasterGy - 02-27-2024, 08:53 PM
RE: Custom MouseMovement Example - by SMcNeill - 02-27-2024, 08:58 PM
RE: Custom MouseMovement Example - by MasterGy - 02-27-2024, 09:07 PM
RE: Custom MouseMovement Example - by NakedApe - 02-28-2024, 02:40 AM



Users browsing this thread: 4 Guest(s)