Add this on Global code :
- Code: Select all
char State[2][8]={"Stop","Walk"};
char Names[4][16]={"Player1","Player2","Player3","Player4"};
char Direction[3][8]={"Left","NULL","Right"};
char AnimName[24]; //to return animation name later
int anim; //to break the animation
int direct; //the direction index, -1=Left, 1=Right
int type; //character index, 0=Player1, 1=Player2, etc...
int state; //state index, 0=Stop, 1=Walk
int attack; //attack index, 0=No attack, 1=Attack
int speed; //or change this value into any value you want
Add this on Player->CreateActor :
- Code: Select all
type=0;
speed=6;
direct=1;
sprintf(AnimName,"%s%s%s",Names[type],State[state],Direction[direct+1]);
ChangeAnimation("Event Actor", AnimName, FORWARD);
Add this on Player->DrawActor :
- Code: Select all
x+=state*direct*speed*(attack==0);
if(attack==0&&anim==0)
{
sprintf(AnimName,"%s%s%s",Names[type],State[state],Direction[direct+1]);
ChangeAnimation("Event Actor", AnimName, FORWARD);
anim=1;
}
Add this on Player->AnimationFinish :
- Code: Select all
anim=0;
attack=0;
Add this on Player->Keydown->Left :
- Code: Select all
if(attack==0)
{
state=1;
}
direct=-1;
Add this on Player->Keydown->Right :
- Code: Select all
if(attack==0)
{
state=1;
}
direct=1;
Add this on Player->Keydown->Punch :
- Code: Select all
sprintf(AnimName,"%sPunch%s",Names[type],Direction[direct+1]);
ChangeAnimation("Event Actor", AnimName, FORWARD);
attack=1;
Add this on Player->Keydown->Kick :
- Code: Select all
sprintf(AnimName,"%sKick%s",Names[type],Direction[direct+1]);
ChangeAnimation("Event Actor", AnimName, FORWARD);
attack=1;
Please note :
In this case, your player must has animation :
- Player1StopLeft
- Player1StopRight
- Player1WalkLeft
- Player1WalkRight
- Player1PunchLeft
- Player1PunchRight
- Player1KickLeft
- Player1KickRight
Good luck
