Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BloodXero

consecutive keyboard inputs

This topic is 5572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i was wondering how to see if cretain keys are being press consecutive times. what im talking about is something like fighting games. for combos you have to press the right buttons in the right order. all i know is how to read one key at a time. any help or tutorials would be nice. What would Jesus do ... for a klondike bar?

Share this post


Link to post
Share on other sites
Advertisement
All you need is a first in first out structure to store each command, which gets fed directly from your input system (i.e. WindowProc or DInput). Give it enough space to store say 10 commands, and you're ready to parse!

[edited by - Thunder_Hawk on February 9, 2003 8:49:07 PM]

Share this post


Link to post
Share on other sites
Heh, going through some old posts...

Here''s something to get you thinking:


  
class FIFO { // First in first out

public:
FIFO () {
for (int i = 0; i < 11; i++) {
data[i] = 0;
}
}
void AddItem (char next) {
for (int i = 1; i < 10; i++) {
data[i-1] = data[i]; // Move all commands down the chain one

}
data[9] = next; // Add new command on the end

}
char* GetCommands () {
return data;
}
private:
char data[11]; // Extra space is for a null terminator :)

}


Then add commands as you receive them and use GetCommands when you''re ready to look for special moves. This isn''t a great example (timing will probably come into the mix), but it should give you some ideas on where to get started (if you haven''t already).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!