Fighting Game Core System Design: From Input Handling to Combo Implementation

    This article explains how to design the core systems of a fighting game. It covers breaking requirements into testable modules, a layered architecture, input buffering, character state machines, hitboxes and damage, energy and super moves, AI difficulty tiers, consistency in local two-player matches, match results, and a testing workflow for edge-case bugs.

    1. Requirements Breakdown: From Page Intent to System Checklist

    A fighting game’s experience has four layers: the first screen, character and stage selection, the handling of controls during a match, and the results and review screen. Key art and character designs usually attract players, but if a match has input lag, inconsistent hit detection, or uncontrolled pacing, players leave quickly. Before development starts, split the features into modules that can be verified, rather than jumping straight into art or UI implementation.

    This project can be split into six feature areas:

    1. Characters and stage: Two independent characters, each with their own move set, hitbox data, and attribute parameters. The stage is a single scene that handles the background, lighting, and ground boundaries.
    2. Match modes: Single player against AI, with easy, standard, and hard levels. Local two-player matches, where both players share one device for input.
    3. Match rules: Best of three rounds. Each round has a time limit and a health cap, and the winner is decided when the round ends.
    4. Basic actions: Blocking, throws, jumping, dashing, airborne states, and combo cancels.
    5. Skill system: Directional-input special moves and full-energy super moves. A super move switches to a close-up camera shot when it triggers.
    6. System functions: Pause and match results.

    After this split, each module has a clear input, state, and output. This step determines whether the architecture stays clear later, and whether each item can be tested on its own.

    2. Overall Architecture: Input, Logic, and Presentation Layers

    Mature fighting games usually divide their code into three layers.

    The input layer reads the device state and converts raw button presses into a unified set of command events. The logic layer handles the rules of combat, including character states, hit detection, damage, energy, and round management. It is the core of the whole system. The presentation layer plays animations and handles effects, camera, UI, and sound. It reads the state from the logic layer but does not modify the logic results.

    The direct benefit of this separation is testability. The logic layer does not depend on the rendering frame rate, so a full match can be replayed without a display, using recorded input sequences, and the results can be compared to check that they match. The AI layer sits on top of the logic layer. It uses the same command interface as human players, and only the source of its input differs.

    3. Input System: Sampling, Encoding, and Buffering

    The goal of the input system is to recognize the player’s actions accurately within logic frames.

    First, the system reads the button state once per logic frame and converts it into three types of events: press, hold, and release. Second, directions are represented with numpad coordinates. For example, 1 is down-left, 5 is neutral, and 9 is up-right. This notation makes it easy to define special moves directly. A motion such as “forward, down, forward plus attack” can be written as the sequence [3, 2, 6] plus an attack button.

    Input buffering is key to how a game feels. Players often enter the next command before the current action has finished. If the system only accepts input after an action ends, the character feels sluggish. So the system should store the most recent few frames of input in a ring buffer and check whether a command matches during the window when the current action accepts input. The length of the buffer window must be tuned through real playtesting. A window that is too short drops player input, and one that is too long causes unintended activations.

    The following pseudocode illustrates command matching:

    1. // Input buffering and motion matching (illustrative)
    2. struct InputFrame { dir: int, buttons: bitmask }
    3. function matchMotion(buffer, pattern, window):
    4. idx = 0
    5. for frame in last_frames(buffer, window):
    6. if frame.dir == pattern[idx]:
    7. idx = idx + 1
    8. if idx == length(pattern):
    9. return frame.buttons has ATTACK_KEY
    10. return false

    A real implementation also needs error tolerance. For example, it should allow diagonal input to replace a cardinal direction, and ignore brief direction changes caused by key chatter.

    4. State Machines: Managing the Action Lifecycle

    Each character’s behavior should be described by a finite state machine. Typical states include idle, walking, dashing, jumping, attacking, blocking, hitstun, throw, airborne, and knockdown. Each state defines its entry conditions, the actions it allows, the moments when it can be interrupted, and its exit conditions.

    An attack usually has three phases: startup, active, and recovery. An action can only be canceled into another action during a specific frame range. This range is the cancel window. For example, after a light attack hits, it can be canceled into a heavy attack during hitstun. If the attack misses, the character usually can only act again after recovery ends.

    Combo cancels are one of the core rules of a fighting game. Write the cancel relationships as a configuration table rather than scattering them across code branches:

    1. // Cancel rule table (illustrative)
    2. cancel_table = {
    3. LIGHT_ATTACK: { on_hit: [LIGHT_ATTACK, HEAVY_ATTACK, SPECIAL], on_block: [SPECIAL] },
    4. HEAVY_ATTACK: { on_hit: [SPECIAL, SUPER], on_block: [] },
    5. ...
    6. }

    A configuration table makes balance changes easier. Designers can adjust the table directly without modifying logic code, and then use replay tests to verify the scope of the change.

    5. Combat Hit Detection: Attack Boxes, Hurt Boxes, and Damage

    The hit detection system decides whether an attack lands and what happens when it does.

    Attack boxes and hurt boxes should be kept separate. An attack box only exists on the active frames of an attack, while hurt boxes change with the character’s body posture. When the two overlap, the system records a hit event and calculates damage, hitstun duration, knockback distance, and energy gain.

    Blocking changes the outcome of a hit. Standing block stops most high attacks, but it is usually ineffective against low attacks. This rule must be clearly marked in the hit data. Throws work differently. They usually cannot get through a block, but a specific state can interrupt or counter them. For this reason, throws should be treated as their own hit type and handled separately from regular attacks.

    Airborne states are the foundation of combos. When a defender enters an airborne state, their body moves along a parabolic arc. They cannot act on their own in the air, and the attacker can keep adding attacks. The height and duration of the airborne state depend on the hit parameters and the gravity constant.

    Combo damage scaling is a common balancing tool. Within one combo, the damage of each following attack decreases by a fixed factor, which limits the reward for endless combos. The scaling factors should be configurable parameters, not hard-coded in attack logic.

    6. Energy System and Super Moves

    The energy meter links offense, defense, and big moves. Energy usually builds from landing hits, being hit, and blocking. The ratio of gain from each source should be tuned to match the pace of the match.

    Once the energy is full, the player can use a super move. A super move needs both the energy condition and the input condition to trigger. When it triggers successfully, the system enters a close-up camera state. Keep two points in mind for this stage:

    First, camera changes and cinematic animations can pause some updates in the presentation layer, but they must not change the hit timing in the logic layer. If a cinematic alters logic frames, the same input may produce different results during replay.

    Second, the invincible frames, active frames, and recovery frames of a super move should be clearly marked and verified frame by frame in testing. These values are balance parameters. They should be recorded in the design document and kept traceable across versions.

    7. Three-Tier Difficulty Design for Single-Player AI

    The single-player AI should use the same command interface as human players. It should only access observable player state, such as current position, action type, and energy level. The AI should not read player inputs before they are made, because this creates an unfair experience.

    Common decision structures include finite state machines, behavior trees, and score-based action selection. For fighting games, a practical approach splits decisions into two layers. The upper layer judges the current strategy from distance, health difference, and energy, such as attacking, defending, or probing. The lower layer picks a specific command from the available actions and adds some randomness.

    Adjust difficulty through several dimensions, not just attack power:

    • Reaction delay: The higher the difficulty, the faster the AI responds to the player’s actions.
    • Decision interval: On easy, the AI makes decisions less often, which leaves it open to gaps in its play.
    • Action set: Easy mode only uses basic attacks and standing block. Standard mode adds basic combos. Hard mode adds throw counters and active use of super moves.
    • Error rate: On easy, the AI has a higher chance of inputting commands incorrectly or dropping combos. Hard mode lowers the error rate.

    Tune the specific delay values and error probabilities through testing. A recommended method is to fix the random seed, run many matches between each difficulty level and the same set of opponent strategies, and track win rate, average round duration, and number of combos. Then adjust the parameters so the differences between the three levels are clear but still fair.

    8. Consistency in Local Two-Player Matches

    Local two-player matches raise two issues: mapping input devices and keeping logic updates consistent.

    Input mapping should let players customize their keys in the settings, with a separate mapping table saved for each player. When both players act at the same time, the system must make sure their input events do not overwrite each other because they share a device.

    Logic updates should use a fixed time step, while rendering can run independently at the device’s refresh rate. This separation ensures that the same input sequence produces the same match result on any machine, and it forms the basis for replay functionality.

    Pausing must freeze both the logic frames and the round timer, while the presentation layer can still show the pause menu. If only the picture pauses and the timer keeps running, the round may end early when the player returns from the pause.

    9. Match Results and Review

    A best-of-three match should record the result and key statistics for each round. The recommended data structures are:

    1. // Match result data (illustrative)
    2. struct RoundResult {
    3. winner: PlayerId,
    4. duration_frames: int,
    5. max_combo: int,
    6. blocks: int,
    7. super_used: bool
    8. }
    9. struct MatchResult {
    10. rounds: list<RoundResult>,
    11. match_winner: PlayerId
    12. }

    The results screen can read this data directly and show the winner, the round duration, and the longest combo. The same data can also support later balance analysis, such as tracking a character’s average combo length or successful block rate.

    Most quality issues in fighting games appear at boundary conditions, so testing should cover the following areas:

    1. State transition tests: Verify the result of every state under every input, and confirm there are no missing or illegal transitions.
    2. Hit detection tests: Check frame by frame how attack boxes and hurt boxes overlap, including simultaneous hits, mutual hits, and results after blocking.
    3. Replay regression tests: Save input sequences from a set of typical matches. After each code change, replay them and compare the final state to confirm it remains the same.
    4. Input feel measurement: Count the frames from a button press to the action appearing on screen, and record the input buffer window length.