I think a shorter way of doing this would be to asign varables to keys so instead of
- Code: Select all
char *key=GetKeyState();
if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_DOWN]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
you would use
- Code: Select all
if (DOWN==0&&LEFT==0&&RIGHT==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (DOWN==1&&LEFT==0&&RIGHT==0)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
else if (DOWN==0&&LEFT==1&&RIGHT==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (DOWN==0&&LEFT==0&&RIGHT==1)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
It dosent shorten the script much but i think it should work faster baceuse the key states are called only from one place instead of each button.
Im sure ,if everyone gives it a little tought, that togheter we can find a better way to do this.