Allow only 4 way movement
Wall Collision
Hey guys, I've finally did it! no moonwalk, no glitches, the perfect anti-moonwalk for RPG games First, make your player, add event ->Draw Actor -> Script Editor, and put this script in.
First, make a variable called STATE, then place this code in Draw Actor
- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP] == 1 && key[KEY_DOWN] == 0){
if (STATE!=90){
if (STATE!=10){
STATE = 10;
ChangeAnimation("Event Actor", "WalkUp", FORWARD);
}
y-=3;
}
if (STATE == 90){
ChangeAnimation("Event Actor", "StandingUp", FORWARD);
}
}
if (key[KEY_UP] == 0 && key[KEY_DOWN] == 1){
if (STATE!=91){
if (STATE!=11){
STATE = 11;
ChangeAnimation("Event Actor", "WalkingDown", FORWARD);
}
y+=3;
}
if (STATE == 91){
ChangeAnimation("Event Actor", "StandingDown", FORWARD);
}
}
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0 && key[KEY_UP] == 0 && key[KEY_DOWN] == 0){
if (STATE!=92){
if (STATE!=12){
STATE = 12;
ChangeAnimation("Event Actor", "WalkingLeft", FORWARD);
}
x-=3;
}
if (STATE == 92){
ChangeAnimation("Event Actor", "StandingLeft", FORWARD);
}
}
if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1 && key[KEY_UP] == 0 && key[KEY_DOWN] == 0){
if (STATE!=93){
if (STATE!=13){
STATE = 13;
ChangeAnimation("Event Actor", "WalkRight", FORWARD);
}
x+=3;
}
if (STATE == 93){
ChangeAnimation("Event Actor", "StandingRight", FORWARD);
}
}
if (key[KEY_UP] == 1 && key[KEY_DOWN] == 1 && STATE == 10){
STATE = 40;
}
if (key[KEY_UP] == 1 && key[KEY_DOWN] == 1 && STATE == 11){
STATE = 41;
}
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1 && STATE == 12){
STATE = 42;
}
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1 && STATE == 13){
STATE = 43;
}
if (STATE == 40){
ChangeAnimation("Event Actor", "StandingUp", FORWARD);
}
if (STATE == 41){
ChangeAnimation("Event Actor", "StandingDown", FORWARD);
}
if (STATE == 42){
ChangeAnimation("Event Actor", "StandingLeft", FORWARD);
}
if (STATE == 43){
ChangeAnimation("Event Actor", "StandingRight", FORWARD);
}
There you have it! I'm enhancing it as well so keep looking for the updates
Here's an Example of Version 1.2