no if anti moonwalk
Posted: Tue Jul 31, 2012 1:13 am
this is an anti-moonwalk system without using if statements. It also uses a pixel system, so you dont start off moving instant speed,m you gain it but seamlessly.
- Code: Select all
char*key=GetKeyState();
int dir=key[KEY_d]-key[KEY_a];
switch(dir)
{
case 0:
switch(animindex)
{
case 2: ChangeAnimation("Event Actor", "charStopLeft", NO_CHANGE);
break;
case 3: ChangeAnimation("Event Actor", "charStopRight", NO_CHANGE);
break;
}
spd=0;
break;
case 1:
spd = min(spd + 1, 7);
x+=spd;
ChangeAnimation("Event Actor", "charRight", NO_CHANGE);
break;
case -1:
spd = min(spd + 1, 7);
x-=spd;
ChangeAnimation("Event Actor", "charLeft", NO_CHANGE);
break;
}