Spielerando

Make a Fighting Game With AI: Timing Comes Before Roster

A fighting game is two characters trading attacks where fractions of a second decide everything, so build two identical fighters with three attacks and a block. Give every attack a wind-up, a moment that hits and a recovery, and leave extra fighters and online play until much later.

Why does this genre live on fractions of a second?

Because each attack is a promise with a price. While you swing, you cannot do anything else. Your opponent can see it coming and answer. That is the entire game, and it all lives in the timing.

Picture two rival market cooks duelling with ladles at a village fair. Here is their whole first move list:

Attack Wind-up Hits for Recovery What it is for
Quick jab 0.10 s 0.05 s 0.20 s Interrupts a slow swing
Heavy swing 0.35 s 0.10 s 0.45 s Big damage, easy to punish
Low sweep 0.20 s 0.10 s 0.35 s Gets under a standing block

Look at what that table does. The jab beats the swing because it lands first. A block beats the swing, and then the cook who swung is stuck in recovery, wide open. The sweep beats a standing block. No attack beats everything, and that is what you are building.

Your AI will happily make an attack that simply plays an animation and subtracts health. Then there is nothing to read and nothing to punish. Ask for the three phases by name, and keep those numbers in a table.

What should exist first?

  1. Two cooks who walk and always face each other.
  2. One attack, with its three phases and a reaction when hit.
  3. Blocking.
  4. A round: health, a timer, a winner.
  5. All three attacks.
  6. Linked hits, using the combo system blueprint.
  7. A computer opponent that follows a few plain rules.
  8. A second fighter who plays differently.

The combo blueprint has ready-made code, and Spielerando can offer it to your AI over an MCP connection. Signing in with Google or e-mail is free, and what you build stays unseen.

Plan for the keyboard too. If two people share one, the keyboard itself may fail you. The Deskthority wiki explains that many keyboards limit which key combinations register at once, which leads to dropped presses. Find out early by holding down both players' keys together, and consider supporting gamepads.

What sinks fighting game projects?

The roster. Eight fighters sounds exciting, and your AI will sketch them in an afternoon. But every fighter has to work against every other, and eight fighters make 28 pairings. You will never get to balance them, and the first two will still feel unfinished.

Online play is the other trap. In a game of fractions of a second, internet delay is brutal, so make it the last thing you consider, if ever. A game two friends enjoy on one sofa is a finished game.

Paste this to your AI

Build a 2D fighting game for two people on one keyboard: two identical fighters, three attacks, one block, and one round with health bars.

Before any game code, draw a fighter as a state machine in a Mermaid diagram: idle, walking, wind-up, hitting, recovery, blocking, hurt, knocked down. Mark which states accept a key press and which refuse it. Go through what happens when both fighters hit at the same moment. Build from that.

Every attack has a wind-up, a hit and a recovery, stored in seconds in one table, and the picture must match each phase.

When you say one attack beats another, show the timing sums from the table, moment by moment. If you have not worked through a pair, say you do not know who wins it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

How to check it worked

  • Press at the same instant. Both fighters should follow the rule you chose for a tie.
  • Punish a swing. Block the heavy swing, then hit back during its recovery. That should always work.
  • Mash one key. Hammering must not let you escape a recovery.
  • Hold all the keys. Both players press everything at once. Note any press that gets lost.
  • Slow it right down. Ask for slow motion. The ladle should touch the cook before the cook reacts.

Sources

Last updated: 2026-11-02