Here's my problem:
I want to make a platformer game. When I jump to the right or left side, there's always a short run animation. I don't want a run animation while I'm jumping/falling. :/
That's the draw actor code:
- Code: Select all
float MSensor=1.2;
char*key=GetKeyState();
xvelocity=(key[KEY_RIGHT]-key[KEY_LEFT])*8;
if(abs(xvelocity)>0&&CollisionFree("Event Actor",x+xvelocity,y-5)&&CollisionFree("Event Actor",x+xvelocity,y-20)==0)y-=2;
else if(CollisionFree("Event Actor",x+xvelocity,y-5)==0)xvelocity=0;
if(abs(xvelocity)>0)PlayerWD=xvelocity/abs(xvelocity);
if(xvelocity>=MSensor&&abs(yvelocity)<=MSensor)ChangeAnimation("Hero", "Bee_Run_Right", NO_CHANGE);
else if(xvelocity<=-MSensor&&abs(yvelocity)<=MSensor)ChangeAnimation("Hero", "Bee_Run_Left", NO_CHANGE);
if(abs(xvelocity)<MSensor&&abs(yvelocity)<=MSensor)
{
if(PlayerWD==1)ChangeAnimation("Hero", "Bee_Stop_Right", NO_CHANGE);
else ChangeAnimation("Hero", "Bee_Stop_Left", NO_CHANGE);
}
if(yvelocity>=MSensor)
{
if(PlayerWD==1)ChangeAnimation("Hero", "Bee_Fall_Right", NO_CHANGE);
else ChangeAnimation("Hero", "Bee_Fall_Left", NO_CHANGE);
}
else if(yvelocity<=-MSensor)
{
if(PlayerWD==1)ChangeAnimation("Hero", "Bee_Jump_Right", NO_CHANGE);
else ChangeAnimation("Hero", "Bee_Jump_Left", NO_CHANGE);
}
if(CollisionFree("Event Actor",x,y+yvelocity)||CollisionFree("Event Actor",x,y+yvelocity+1)){yvelocity+=0.4;Jump=0;}
else {yvelocity=0;if(CollisionFree("Event Actor",x,y+yvelocity-4)==0)Jump=0;else Jump=1;}
yvelocity-=key[KEY_SPACE]*Jump*8;
Got it from a mario example on this forum.
I hope somebody can help me~