Stopping Key And Mouse Button Repeating by WhizzRich13th May 2004 5:56
|
---|
Summary To make a key or mouse button work only once, no matter how long you hold it for. Description For use in every single game you could possibly make. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com dim key(250) : dim oldkey(250) if mouseclick > 0 then oldmouse = 1 if mouseclick() > 0 and oldmouse = 0 : mouseclick = mouseclick() : else : mouseclick = 0 : endif if mouseclick() = 0 then oldmouse = 0 for a = 1 to 250 if key(a) = 1 then oldkey(a) = 1 if keystate(a) = 1 and oldkey(a) = 0 : key(a) = 1 : else : key(a) = 0 : endif if keystate(a) = 0 then oldkey(a) = 0 next a `when actually checking the key, simply do this: if key(scancode of key) = 1 `and for checking a mouse button (left button = 1, right button = 2 etc): if mouseclick = 1 |