Computer Science Canada

3 Key Combinations

Author:  VB_User [ Thu Apr 03, 2003 4:14 pm ]
Post subject:  3 Key Combinations

Hey i need some help. I am having trouble with my mortal kombat clone. I am trying to make it so that when the person hits a certain three key combination a special moves happens. Example would be something like back, back , z makes you shoot a fire ball. Now ive written code to do this every way that i can think of and all of them have bugs with them. If anyone has any ideas let me know.


Author:  Catalyst [ Thu Apr 03, 2003 4:42 pm ]
Post subject: 

have you tried Input.KeyDown, it will let you see which keys are down (i dont have the syntax in memeory so just F9 it)

Author:  Tony [ Thu Apr 03, 2003 4:47 pm ]
Post subject: 

we got a tutorial on that actually Very Happy

Author:  VB_User [ Thu Apr 03, 2003 5:30 pm ]
Post subject: 

This doesnt seem to work with turing 3 which is what im using

Author:  Tony [ Thu Apr 03, 2003 5:35 pm ]
Post subject: 

oh yes... few posts lower of the tutorial I mentioned it Confused I'll update it Razz

but yeah, it doesnt work in v3 so you cant have more then 1 key pressed at a time. Sorry

Author:  VB_User [ Thu Apr 03, 2003 5:49 pm ]
Post subject: 

This is really really really stupid. All the features i want in version 3 are only in version 4 and the features i want in version 4 are only in version 3. There must be a way to do what i want to do. I also dont want three buttons pressed at once but one after another. like up , up , down or something like that. I also want it so you have to press them with in a second of eachother.

Author:  AsianSensation [ Thu Apr 03, 2003 6:00 pm ]
Post subject: 

I don't know if I can help on the actual coding, but I have an idea. Have a function that uses a timer, and let the user input from the keyboard, then see the time elapsed between each input, if it is within range of your predefined range, then execute a program.

p.s. Not sure if this method will work with 3.1

Author:  Tony [ Thu Apr 03, 2003 6:12 pm ]
Post subject: 

here's what you do then...

you have a string for the buffer and every time you press a key you add it to the end of it. Then right after it check the timer and if a second has passed, you drop the first letter of the input buffer.

then you can use index command to search through the buffer to see if any special conbinations are present.

To add a letter to the end
buffer += letter

To remove first letter
buffer := buffer(2..*)
Assuming buffer is always altleast 2 characters long

Author:  VB_User [ Fri Apr 04, 2003 12:05 pm ]
Post subject: 

I cant get the timer working correctly. What i want it to do i want it so you have to hit a 3 key combination with in 2 seconds. If you dont hit it within the 2 seconds the buffer variable will go back to " ". I cant get the time working though

Author:  Tony [ Fri Apr 04, 2003 2:40 pm ]
Post subject: 

after you hit the first key, assign that to a buffer and take note of the time wallclock. then after each next key, you add that to the buffer and check the new time (also wallclock).

you also check if that buffer contains your combination.

then you check if the difference between two times is >= 2 seconds and if so, you clear the whole buffer.

putting buffer somewhere on the screen would help you figure out timing and stuff... like in most fighting games on practice mode.

Author:  VB_User [ Fri Apr 04, 2003 4:55 pm ]
Post subject: 

is wallclock the time in seconds that something started? and can i set it so that if its above 2 seconds that it goes back to zero and when they hit the button again it times again.

Author:  Tony [ Sat Apr 05, 2003 1:22 pm ]
Post subject: 

wallclock is time in seconds since January 1, 1970. By taking wallclock two times and finding their difference, you find out how much time has passed between two points (in seconds though).

Author:  Catalyst [ Sat Apr 05, 2003 2:21 pm ]
Post subject: 

u can get milliseconds with clock()