Hold Buffers

My favorite kind of input buffer by far is a hold buffer.

How does it work?

The idea is pretty simple. Once you press a button, that buttons is buffered. It stays buffered until:

Here are the benefits to this kind of buffer system over a normal 5 frame buffer for example:

Implementation Overview

The easiest way to implement this in my opinion is to keep a list of buffered buttons, or a dictionary of button names with Booleans for whether they're buffered or not. Then you define the following two functions:

First is a "handle buffer" function that runs each frame and does the following for each pressable button your game has (for example ABCD or LMH):

Then a "check buffer" function which takes a button as input:

Then whenever you want to check for a button press for an attack, you use the check buffer function. Just make sure you check all the other requirements for the attack first so you don't eat any inputs.

Technical Implementation

The following is an example of how you implement a hold buffer in Python. In this case self.Buffer, InputsThisFrame, and self.InputsLastFrame are all dictionaries with the keys being button names, and the values being Booleans.

def HandleBuffer(self,InputsThisFrame):
	# Inputs is a dictionary here
	for ButtonName in InputsThisFrame:
		if not InputsThisFrame[ButtonName]:
			# If we're not holding the button, unbuffer it
			self.Buffer[ButtonName]=False
			continue
		if self.InputsLastFrame[ButtonName]:
			# If we were already holding it, don't change the buffer
			continue
		# If we pressed it this frame, add it to the buffer
		self.Buffer[ButtonName]=True

def CheckBuffer(self,ButtonName):
	if self.Buffer[ButtonName]:
		# Remove it from the buffer now that it's been used
		self.Buffer[ButtonName]=False
		return True
	else:
		return False

Addendum: Adding a time limit

Some games prefer to add a time limit so the buffer doesn't last forever even if you hold the button forever. The fix for this is very simple.