Handling input for a toggled mode

Blitz3D Forums/Blitz3D Beginners Area/Handling input for a toggled mode

In a kind of long-winded way, I check against my timing variable and take no action if it has been actioned withini the last 100 ms or so. I understand calls to millisecs() are quite slow, though.

To maintain accuracy of MouseX and MouseY, convert these to variables at the moment of clicking.

_________EDIT_______________


Here's some edited code from Galactic Allegiance.

very simply, there is a little routine where ANY button-press controls are dealt with, only the routine is skipped if any of the keys were pressed within 150ms...

.KEY_CONTROLS


	If MilliSecs()-keytime>150

		If KeyDown(47) Then Gosub CAMERA_VIEWS
	
		If JoyDown(3) Then ChangeTarget$="Back" Gosub CHANGE_RADAR
		If JoyDown(4) Then ChangeTarget$="Forward" Gosub CHANGE_RADAR
	
		If KeyDown(29) Then DisplayLabels=1
	
	keytime=MilliSecs()
	
	FlushKeys
	
	EndIf
	
Return


You would simply substitute in for your code like this:

.KEY_CONTROLS


	If MilliSecs()-keytime>150

		If MouseDown(1) Then displaygrid=(1-displaygrid)

	keytime=MilliSecs()
	
	FlushKeys
	
	EndIf
	
Return