Sign in to follow this  
shezad

Input fighting game

Recommended Posts

shezad    136
Hi, I did investigate a little bit about game input, I've read that if I want to check for multiple buttons I need to create a buffer etc...etc...etc...now my doubt is : If I have two systems, the first one sends a request for an event when I push the button "H" for example, another system checks if I get multiple buttons, for example "H" plus "T" send a different event comparing to "H" alone, the question is how do I decide if the button I press is the start of a new combination or I need to send the event immediately? Cheers

Share this post


Link to post
Share on other sites
Faelenor    396
Your input should all be filtered at the same place to prevent this kind of problem. Also, you should send the request on the release of the buttons instead of the press. That way, you won't send the H request before you know if the player pressed also the T button.

Share this post


Link to post
Share on other sites
mrobbins    132
I may not be understanding your question properly but if you want to check for combos in a fighting game then why not implement a queue of button presses.

For example, when the user presses a button add it to the queue of button presses of a fixed size (whatever your maximum combination is). Then each time a button is pressed iterate over the queue and compare the sequence in the queue to the sequences for a combo. If the sequence is found, trigger the move, clear the queue and start again.

Share this post


Link to post
Share on other sites
shezad    136
This is the solution I found so far.
I create a window of 0.5 seconds, during this window I don't send any input to the game, after 0.5 seconds i start to analize the input buffer checking immediately if it's a single key or a multiple sequence.

if(windows>0.5s)
{

checkTheBuffer();
sendTheEvent();
}
else
{

keepFillingTheBuffer();
}

I am only a bit concerned about the lag because during the 0.5 secons I don't send any signal to the game but because is the first time I try to do something like that I am not sure of the impact of this window on the game.

Any better idea?

Thanks

Share this post


Link to post
Share on other sites
OldProgie2    158
Have a key map. Your input system will handle key up/down events and update this map. Any systems that are interested in the state of the keys will take a copy of that map and query it in some way for the information it wants.

e.g. (in pseudocode)
class KeyMap
{
map m_keyMap;

handleKeyEvent(event e)
{
if (e.keydown)
{
map(e.key).keyDown = true;
}
if (e.keyup)
{
map(e.key).keyDown = false;
}
}

map &getKeys()
{
return m_keyMap;
}
}


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this