Fighter Physics

Section Overview

In this section, the physics of how a character's position and motion will be laid out. This is technical documentation for how the game will calculate characters and positions.

+Definable Variables

.stats file

Each character has a stats file, stored in "characters/[NAME]/[NAME].script" This is a file that is read by the engine as a simple script. Several variable relating to the character can be directly edited here, and the engine will use these values at runtime.

Should the file be missing, the engine will simply resort to arbitrary defaults, because undefined variables make the runnable ill.

jumpVel - Velocity with which a jump will begin. Does not depend on anything else; this is really just the raw, 'bullet-leaving-gun- velocity. (I may make this calculated based on desired jump height- Chris)
fric - friction of the character. The character will have their ground velocity reduced based on this value once every 1/60 of a second. (every frame).

moveVel - How far the character moves per frame. The character will have their ground velocity increased by this amount once per frame, if the control stick is completely held left/right,

maxSpeed - Maximum ground speed the character can achieve through running.

jumpDelay Time between a character receiving a jump command, and actually jumping. In frames.

tumbleTime - Minimum amount of time a character will be stunned for.

dodgeTime duration of a spotDodge in which a player is invulnerable.

guardMax - Maximum arc of a player's guard in either direction, in degrees. (ie; an arc of 90 degrees would block all attacks on one-half the fighter)

Calculated definables

int playerNum - numerical identity of player (Player 1, player 2 and such)

int cID - numerical identy of the fighter the player has chosen (Serenity 0, Yara 1)

State variables

point pos - location of the character in x,y coords

point vel - velocity of the character, with x, y being the vector of the character's expected location one frame from now

point accl - acceleration of the character. Is added to vel once per frame, and is reset once per frame.

point move - no hassle relocation of a character. Useful for teleports, dashes, lunging. Does not affect vel or accl.

int state - integer value relating to the current state of the character.

int lastState - state the character was previosly in, for the last frame. (useful for determining change)

double damage - how much damage the character has taken this stock.

double guardArc - current value of the character's guardArc, in degrees (limited by guardMax)

int stocks - lives/rounds left

double groundSpeed current speed of character along ground.

int attkType - identifier of the charcter's attack, if active.

bool isFacingRight - boolean determining which direction the character is facing.

**bool airborne* - true when airborne, false when on the ground.


Movement has two modes, depending on the value of airborne. If airborne is true, the character will move along a vector, with gravity applied. Some friction will be applied as air resistance, and the player may still not move faster than *maxSpeed*.

Else, the engine considers the player to be grounded, and will instead track the character along slopes. The character's horizontal movement will remain constant; no matter how steep the slope, the character will move left or right at the exact same horizontal speed. At the end of each frame a check will be used to reposition the character on the ground. If the ground is too far away, airbone is not repositioned.

When Airborne

accl.x will take a value dependent on the x position of the control stick, to be added/subtracted from the character's velocity.

accl.y will be equivalent to the player's gravity, and subtracted from the movement vector each frame.

vel will contain the x,y vector of which direction the character is currently facing.

airborne is set to false when the character lands on a walkable surface.

Not Airborne

accl.x will be added to groundSpeed

groundSpeed will determine how far, left or right, the character will travel. Slope or .y is irrelevant.

groundSpeed will have the character's *fric*tion subtracted from it each frame.

groundSpeed cannot exceed maxSpeed

The player will 'stick' to the floor unless they walk off a platform or jump.


When a jump is detected, the game will count down frames (or, 1/60ths of a second) according to the character's jumpDelay. Once these many frames have passed, the character will launch up with an initial velocity according to jumpVel.

Characters may have more than one jump before hitting the ground. Specialized jumps may be used, determined on specific input after the jump command has been made, before the jumpDelay ends.

Edge Grabbing

Each character has a predefined 'grab hitbox' visible in debug mode. This hitbox is only active when a character is airborne, and either falling or about to fall. If the grab box collides with a grabbable edge the character will grab it. Pressing up will cause the character to ledge climb. Moving towards the edge will cause a ledge roll. If either 5 seconds pass or the player hits down, they will drop. No action is taken for moving the stick away from the edge.