๐ŸฅŠ Episode 6 ยท Advanced ยท States

Write the Rules
Episode 6: States and Constants

States are the heart of a fighter: what it does, when input is allowed, and what happens on a hit. This is the biggest idea in MUGEN, so we take it slowly.

๐Ÿ‘ถ Ages 10+ โฑ๏ธ ~1 hour ๐ŸฅŠ MUGEN โœ“ Free workshop
๐Ÿง  Statedef ๐ŸŽ›๏ธ Controllers ๐Ÿ“Š Constants ๐Ÿ”— Changes
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress 0 / 5 steps
Build it in our MUGEN Studio too: set up a fighter, add sprites and poses, place hitboxes and export a real fighter folder in the browser, with no install. Open the MUGEN Mod Studio →
๐Ÿ”ฅ
Ember says: a mind is just rules. A state says "when you are in this situation, do these things". Stack enough rules and your fighter feels alive.
1
๐Ÿง 
A State Block
The situation
Active
๐ŸŽฏ
Goal for this step

Read a [Statedef] block.

  • 1A state starts with [Statedef N], where N is the state number.
  • 2It sets things like type (stand/crouch/air), movetype (idle/attack), physics and which anim to play.
  • 3ctrl = 1 means the player can still control the fighter.
[Statedef 200]
type = S
movetype = A
physics = S
anim = 200
ctrl = 0
โœ๏ธ
Fill in the Blanks
+15 XP
A state begins with and a number.
๐Ÿง 
Knowledge Check
+15 XP
What does ctrl = 1 mean in a state?
AThe player can control the fighter
BThe fighter is frozen
CThe state is deleted
2
๐ŸŽ›๏ธ
Controllers
The instructions
Locked
๐ŸŽฏ
Goal for this step

Understand a controller inside a state.

  • 1Inside a state, each [State ...] block is a controller: one instruction.
  • 2Controllers have a type (like VelSet, ChangeState, PlaySnd) and trigger lines.
  • 3The controller only runs when its triggers are true.
โœ๏ธ
Fill in the Blanks
+15 XP
Each instruction inside a state is called a .
๐Ÿง 
Knowledge Check
+15 XP
When does a controller run?
AWhen its triggers are true
BEvery frame always
CNever
3
๐Ÿ“Š
Constants
The fighter statistics
Locked
๐ŸŽฏ
Goal for this step

Read the [Data] and [Size] constants.

  • 1[Data] sets life, attack and defence.
  • 2[Size] sets the fighter hitbox sizes and shadow.
  • 3[Velocity] sets walk and run speeds.
โœ๏ธ
Fill in the Blanks
+15 XP
The fighter life, attack and defence live in the constants.
๐Ÿง 
Knowledge Check
+15 XP
Where do you set how much life a fighter has?
A[Data] constants
BThe .snd file
Cselect.def
4
๐Ÿ”—
Moving Between States
ChangeState
Locked
๐ŸŽฏ
Goal for this step

Send the fighter from one state to another.

  • 1ChangeState with a value moves the fighter to a new state number.
  • 2A punch state ends by changing back to the idle state.
  • 3This is how a whole fighting game chains together.
โœ๏ธ
Fill in the Blanks
+15 XP
To leave a state, use a ChangeState .
๐Ÿง 
Knowledge Check
+15 XP
How does a punch state return to idle?
AIt changes state back to idle at the end
BIt restarts the game
CIt cannot
5
๐Ÿงช
Test One Move
Make a punch land
Locked
๐ŸŽฏ
Goal for this step

Wire one move end to end and test it.

  • 1Command fires, state triggers, animation plays, controller returns to idle.
  • 2Test in a match and watch the move happen.
  • 3If nothing happens, check the command name matches the state trigger exactly.
โœ๏ธ
Fill in the Blanks
+15 XP
If a move does nothing, check the command and trigger match exactly.
๐Ÿง 
Knowledge Check
+15 XP
A move does nothing. First thing to check?
AThe command name matches the state trigger
BThe music
CThe window size
๐ŸŽ‰โœจ๐Ÿ†๐ŸŽ‰
Your Fighter Has Rules!
You can write states and constants and chain moves. Next you make attacks actually connect with hitboxes.
0
Total XP
1
Level
0
Best Streak
0%
Accuracy
Next: Episode 7: Hitboxes โ†’