Flush individual key?

Blitz3D Forums/Blitz3D Programming/Flush individual key?

LamptonWorm(Posted 2009) [#1]
Hi everyone,

Is it possible to flush a single key as opposed to all keys (flushkeys())?

Cheers,
LW.


GfK(Posted 2009) [#2]
No.


Guy Fawkes(Posted 2009) [#3]
He's right. I'm afraid not dude..

sorry


_PJ_(Posted 2009) [#4]
If you are wanting to limit repetition I use a kinda delay in the keypress routine:


;Before Main Loop
Global LastFired=Millisecs()


; During Main Loop
If Keydown(52)
If ((Millisecs()-LastFired)> 50 ); 50 here is the 'fastest' repetition of the keypress 'allowed'. 
LastFired=Millisecs()
; Do fire stuff as normal
End If
End If



LamptonWorm(Posted 2009) [#5]
Hi,

Thanks for the speedy reply.. no worries, just checking I wasn't missing anything obvious!

Cheers for the snippet Malice, but I've got something slightly different to solve, I have 2 players sharing the keyboard and only need to flush the dying players keys.. but I think there are other ways around it but a simple single key flush would be easiest :) but no worries, need to re-plan a little 'tis all.

Cheers,
LW.


GfK(Posted 2009) [#6]
Pseudocode:
CheckKeys()
If Player = Dead
  DontMovePlayer()
EndIf

??


_PJ_(Posted 2009) [#7]
yeah, as Gfk hints at, I would think that it may be best to simply add in a check and if that player is 'dead or dying', then skip the section of code that deals with checking their movement keys, or applying the movement.


LamptonWorm(Posted 2009) [#8]
Hi,

I'm already doing that.. the problem is that without doing a flush, that during the dying sequence any key hits are still added to the keyboard buffer, and it just so happens that the key to start the players next life is also their movement key. In this game you have 1 life btw.

I can get around it by having another key as the start key, but I wanted to avoid this if possible, as it breaks one of the design rules specific to the game.

Other options are split the control methods to key, mouse, or key, joy, so I can independenty flush stay presses between dying and new life starting.

Cheers,
LW.


LamptonWorm(Posted 2009) [#9]
Hey, think I've nailed it.. the player goes into their dying/reset I can reset the keyhit count by simply calling keyhit(203) on its own. I've always used keyhit as 'if keyhit(203) = 1 then..', forgot it returns the count between keyhit calls. so I reset it, by calling it at the right time (during player reset) and it acts as a flush.. need to test it more now but I think it is working as needed.


Guy Fawkes(Posted 2009) [#10]
good job:)


Adam Novagen(Posted 2009) [#11]
That should definitely work, and it's a nicely out-of-the-box solution. Bravo!


_PJ_(Posted 2009) [#12]
Yeah, I am so used to Keydown I forget the other commands.

It makes sense and should work ideal. Well thought :)


Guy Fawkes(Posted 2009) [#13]
ahaha.

im so used to fusing them.

lol

:P

"moveentity cam, 0, 0, (keydown(200)-keydown(208))*1
turnentity cam 0, (keydown(203)-keydown(205))*1,0"

:P


LamptonWorm(Posted 2009) [#14]
Cheers folks. I've done a bit more testing and this appears to be working fine, cool.

Cheers,
LW.


cryptadone(Posted 2014) [#15]
at my advice its possible

dim a1$(100)

repeat

repeat

a$=inkey$

aa=aa+1

if a$<>"c" then a1$(aa)=a$

until a$=""

until keyhit(1)


end


; so get the last key$ in the array a1$()...