Computer Science Canada How do you get turing to recognize successive button pressed |
Author: | born130 [ Thu Jun 26, 2003 2:53 pm ] |
Post subject: | How do you get turing to recognize successive button pressed |
Hello, My question is how do you get Turing to recognize several buttons pressed in succession? for example: i am making a game that wants you to press say "left arrow, right arrow, left arrow, left arrow" in succession inorder to do a combo move. any help is appreciated Thanks |
Author: | AsianSensation [ Thu Jun 26, 2003 2:57 pm ] |
Post subject: | |
could use getch and have a key buffer, then calculate the amount of time it takes between each input, if the time is over certain level, then take a character away from the buffer. anyways, I believe there is a topic on this already, so y don;t u search the help forum. |
Author: | Homer_simpson [ Thu Jun 26, 2003 3:03 pm ] |
Post subject: | |
most keyboards dont detect more than 4 keys at once... u can use getch but it's pretty slow =/ |
Author: | Andy [ Thu Jun 26, 2003 3:57 pm ] | ||||
Post subject: | |||||
born130 what u need is an array from 1 to how many keys you want to be pressed read my tutorial on arrays if u dun know how to use them http://www.compsci.ca/bbs/viewtopic.php?t=1117 ok you want the array to be integers containing the ascii number of the keys you want so have something like this
now all you need to do is have a loop and go in the following code counter is which key ur currently at if the user messes up, the counter resets to 0. count is the number of keys the user needs to end the program
|
Author: | born130 [ Thu Jun 26, 2003 4:26 pm ] | ||
Post subject: | |||
So how do I put the keys in to be recognized? i.e. how do i declare which keys to be pressed in the right order
|
Author: | Andy [ Thu Jun 26, 2003 4:29 pm ] |
Post subject: | |
no no no okay lets say there are 3 keys, you juss go keystroke(1):=ord("a") keystroke(2):=ord("b") keystroke(3):=ord("c") |
Author: | born130 [ Thu Jun 26, 2003 4:48 pm ] | ||
Post subject: | |||
so my question was how do i get them to recognize the buttons pressed second question is does this code only work for the buttons pressed simutaneously? because my goal is for it to be pressed succesively i.e. press "a" then "b" then "c" ...etc. |
Author: | Andy [ Thu Jun 26, 2003 6:00 pm ] |
Post subject: | |
no born130, this code only works for buttons pressed one after another... y do you have the array to size 5 when you only need 3 buttons? just change the keystroke (1) := ord ("a") keystroke (2) := ord ("b") keystroke (3) := ord ("c") keystroke(1) is the first input (2) is the second and so on the buttons are inside the ord() |
Author: | PaddyLong [ Thu Jun 26, 2003 6:05 pm ] | ||||||
Post subject: | |||||||
here is an explanation.... hopefully this clears up how it works for you born this section of code declares the keys that are to be pressed (in this case, it would be that it is expecting the user to press a, then b, then c)
the counter keeps track of how far into the progression of key strokes the user is.. so which index of keystroke it is expecting next
|