Page 1 of 1

code help

Posted: 10 Dec 2013 13:44
by princesstwi
i was wondering if it is possible to make a batch code so they have to hit a certain key a certain amount of times with in a limited time if they dont they go to :fail if they do they goto :success

post code if possible if you dont want to post a code for it just tell me wether its possible or not

Re: code help

Posted: 10 Dec 2013 17:32
by ShadowThief
The easiest way to go about doing this would be to get the system time, have the user hit the key x number of times, get the system time again, and compare the two times, going to :fail if the difference between the two times is greater than whatever threshold you were thinking of.

However, I get the impression that you want the other kind of "do-a-thing-x-times-in-under-y-seconds" where the timer counts down while the user is hitting the button. I've never personally implemented anything like that, but I've seen topics on here about multithreading and Dave Benham's SNAKE game looks for key presses while the program is doing other things by using XCOPY, so it's definitely possible.

Re: code help

Posted: 11 Dec 2013 09:13
by princesstwi
thankyou for the reply thats what i needed to know :D