Overview
This class is an extension to c_Sprite and is used to control the player's avatar or 'fighter' along the screen.
Constants and statics
static const int IDLE….EDGEROLL : these are the indices of every state the player can enter.
MAX_TRACKS; the maximum amount of tracks a single attack can contain.
It is a companion class to c_Player and c_FighterStats
void c_FighterSprite::Load(GrEngine* eng, LPCSTR file, SPoint p)
Loads the resources assocated with the fighter into the engine. Passes the parameters to c_Sprite::Load().
Parameters:
GrEngine* eng Graphics engine object; required
LPCSTR file resource file location
SPoint p; starting location of the sprite.
bool c_FighterSprite::Idle()
This function sets the sprite to an idle state if it is able to, returning true int his case.
The first if statement is a length check to make sure the sprite is eligble for the state. If so, the Idle animation is played.
Else, the player may be walking so a check to see if that animation should be played occurs after.
—-
bool c_FighterSprite::Attack(int aI, LPCSTR aS)
Plays the attack animation for a given attack
Parameters:
aI: index of the attack.
aS: String for resource location of the attack.
bool c_FighterSprite::Jump(double jumpDelay)
Causes a jump. Note that there are 2 kinds of jumps, a jump from the ground will occur several frames into the future, where a jump in the air will be immediate. This function handles the case with delay.
JumpDelay is the time the jump is scheduled to occur.
void c_FighterSprite::Jump()
The case of an immediate airjump, or a jump that is queued to occur now
void c_FighterSprite::Crouch()
Causes the player to display a crouch animation.
bool c_FighterSprite::Walk(double lStart, double lStickX)
Updates and runs the player's walk animation
—
bool c_FighterSprite::Dash()
Starts a dash, if elligible.
void c_FighterSprite::FighterPivot();
Pivots the fighter. Handles the case where a pivot is made mid-pivot, and sanitizes the end result to keep players facing in the proper direction.
bool c_FighterSprite::SpotDodge()
executes a spot dodge in place.
bool c_FighterSprite::StateChange()
returns true if a state change occured since the last frame
bool c_FighterSprite::RevertState()
reverts the state to that it was in during the last frame
void c_FighterSprite::FaceRight(bool t)
Causes the player to face right (or left, if t is false)
void c_FighterSprite::EdgeGrab()
Performs an edge grab with the sprite
void c_FighterSprite::Fall();
Updates the fighter for a fall animation
void c_FighterSprite::Land()
Lands the player on the ground, updates .airborne
void c_FighterSprite::GetUp();
Cues the player to get up, if knocked down onto the ground
void c_FighterSprite::BufferNextAnim(std::string nName);
buffers an animation defined by 'nName', to be played immediately after the current animation ends.
bool c_FighterSprite::EdgeClimb(SPoint &pos)
Performs an edge climb.
bool c_FighterSprite::EdgeRoll(SPoint &pos)
Performs an edge roll.
bool c_FighterSprite::InState(int s)
Returns true if the fighter is in the state specified by the index 's'
bool c_FighterSprite::InAttack(int a)
Returns true if the fighter is in the attack specified by the index 'a'
bool c_FighterSprite::CanPivot();
returns true if the fighter is able to pivot this frame.
void c_FighterSprite::UnCrouch()
Returns to standing, from a crouch.
bool c_FighterSprite::Update(double timeLapsed)
Updates the sprite according to the time lapsed. Handles uncrouching as well as updating the current animation, and the buffered animation if it exists.
void c_FighterSprite::PostUpdate()
A post-update function, aids with the last phase of the [main attack loop
int c_FighterSprite::GetAtkType()
returns the index of the current attack
void c_FighterSprite::SetStatsSPointer(c_PlayerStats* p)
links the instance of this class with the companion c_PlayerStats
void c_FighterSprite::Tumble()
sends the fighter into tumble and displays the animation.
variables
void c_FighterSprite::Tumble();
STimer actionTmr : timer assocated with the current action the fighter is taking.
double frame : frame of the current animation to display
bool isFacingRight : whether the player is facing right
bool airborne : false if player has left the ground
int state : holds the current state of the player
int atkType : current attack the player is engaged in, if any
int lastState :state the player was in last frame
c_PlayerStats* statsPtr : link to player stats class
double sScale; //legacy to fix scaling issues
std::string animName : name of current animation
std::string nextAnim; : name of buffered animation
double animLoopStart : start time of a looped animation