Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 3 Key Combinations
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
VB_User




PostPosted: 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.

Thanks
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Thu Apr 03, 2003 4:42 pm   Post subject: (No 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)
Tony




PostPosted: Thu Apr 03, 2003 4:47 pm   Post subject: (No subject)

we got a tutorial on that actually Very Happy http://www.compsci.ca/bbs/viewtopic.php?t=114
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
VB_User




PostPosted: Thu Apr 03, 2003 5:30 pm   Post subject: (No subject)

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




PostPosted: Thu Apr 03, 2003 5:35 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
VB_User




PostPosted: Thu Apr 03, 2003 5:49 pm   Post subject: (No 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.
AsianSensation




PostPosted: Thu Apr 03, 2003 6:00 pm   Post subject: (No 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
Tony




PostPosted: Thu Apr 03, 2003 6:12 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
VB_User




PostPosted: Fri Apr 04, 2003 12:05 pm   Post subject: (No 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
Tony




PostPosted: Fri Apr 04, 2003 2:40 pm   Post subject: (No 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
VB_User




PostPosted: Fri Apr 04, 2003 4:55 pm   Post subject: (No 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.
Tony




PostPosted: Sat Apr 05, 2003 1:22 pm   Post subject: (No 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).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Catalyst




PostPosted: Sat Apr 05, 2003 2:21 pm   Post subject: (No subject)

u can get milliseconds with clock()
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: