BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Mouse lag simulation"
, by thechange
A relatively simple way of simulating delayed and indirect mouse movement.
Code
; Mouse lag simulation by letting the mouse indirectly ; control a virtual mouse cursor. Const SX = 640 Const SY = 480 Const MaxSpeed = 5 Const Momentum# = 0.1 Graphics SX , SY SetBuffer BackBuffer () HidePointer MX# = 320 MY# = 200 Repeat ;-- Horizontal movement -- MoveX# = MouseXSpeed () ;-- Remove acceleration -- If MoveX > 0 Then MoveX = 0.4 If MoveX < 0 Then MoveX = -0.4 ;-- Momentum -- If MoveX <> 0 IncX# = IncX + MoveX Else If IncX < -Momentum IncX = IncX + Momentum ElseIf IncX > Momentum IncX = IncX - Momentum Else IncX = 0 End If End If ;-- Vertical movement -- MoveY# = MouseYSpeed () ;-- Remove acceleration -- If MoveY > 0 Then MoveY = 0.3 If MoveY < 0 Then MoveY = -0.3 ;-- Momentum -- If MoveY <> 0 IncY# = IncY + MoveY Else If IncY < -Momentum IncY = IncY + Momentum ElseIf IncY > Momentum IncY = IncY - Momentum Else IncY = 0 End If End If ;-- Speed limiting -- If IncX < -MaxSpeed IncX = -MaxSpeed End If If IncX > MaxSpeed IncX = MaxSpeed End If If IncY < -MaxSpeed IncY = -MaxSpeed End If If IncY > MaxSpeed IncY = MaxSpeed End If ;-- Update real mouse -- MX = MX + IncX MY = MY + IncY ;-- Clip and bounce -- If MX < 0 MX = 0 IncX = 0 End If If MX >= SX MX = SX-1 IncX = 0 End If If MY < 0 MY = 0 IncY = 0 End If If MY >= SY MY = SY-1 IncY = 0 End If ;-- Center mouse -- MoveMouse 320 , 200 ;-- Display -- Rect MX , MY , 10 , 10 , False Flip Cls Until KeyHit ( 1 ) End
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations