3
\$\begingroup\$

Ok guys, I understand how to make a basic input buffer.

Here is my code:

public class InputBuffer : MonoBehaviour {

    public int max_buffer;
    public enum keys { down, up, left, right, X, Y, Z, A, B, C }
    public List<keys> InputPlayer;
    public enum Special { WPunch, MPunch, SPunch, WKick, MKick, SKick, Hadouken, Shoryuken }
    public List<Special> SpecialsPlayer;

    void Start () {
        InputPlayer = new List<keys>();
        SpecialsPlayer = new List<Special>();
    }

    void AddKey(keys key)
    {
        InputPlayer.Add(key);

        if (InputPlayer.Count > max_buffer)
        {
            InputPlayer.RemoveAt(0);
        }
    }

    void CheckSpecial()
    {
        if (InputPlayer[InputPlayer.Count-1] == keys.A)
        {
            if (InputPlayer[InputPlayer.Count-2] == keys.right)
            {
                if (InputPlayer[InputPlayer.Count-3] == keys.down)
                {
                    SpecialsPlayer.Add(Special.Hadouken);
                }
            }
        }
    }
}

This works really well, but then I get repeated keys in the buffer when I keep a key pressed.

I could fix it by having a last keypressed variable and then only calling the inputbuffer.getkey if the key pressed is diferent. But this makes the buffer to behave rather stiff.

I would love to see how can I improve my code so It doesn't recognizes multiples keys when a button is kept pressed, but also allow for charge moves (Guile's sonic boom).

I also would love to see how input shortcuts works (using a previous special command as part of a second one, usually used in cancels to supers).

I would love to see what's the proper way to handle input buffers in kof and SF.

\$\endgroup\$
  • 2
    \$\begingroup\$ Possible duplicate: gamedev.stackexchange.com/questions/43708/… \$\endgroup\$ – MichaelHouse Mar 13 '15 at 17:26
  • 1
    \$\begingroup\$ I don't think it's a duplicate. Cristian asked for behaviors not mentioned in the post you linked, such as reuse part of the same inputs in a special and a super. \$\endgroup\$ – Emir Lima Mar 13 '15 at 19:25
  • \$\begingroup\$ What makes the input buffer or a normal fighting game different from that of a professional fighting game? \$\endgroup\$ – JPtheK9 May 29 '15 at 17:43
0
\$\begingroup\$

store the flag for each key and set it true on keydown. don't add this key to buffer while corresponding flag true. set flag to false when keyup happens.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.