02-27-2024, 08:53 PM
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.
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