moving and attacking
Posted: Tue Sep 04, 2007 6:44 am
Hey guys im back again, and I need help.
I used the code from http://game-editor.com/forum/viewtopic.php?f=2&t=1655&start=0&st=0&sk=t&sd=a this thread to make myself a walking script. However, I cannot seem to add an attacking feature to it. Can anyone show me what to add and how so that when I press 'L" the player changes to his attack animation. The player can still move while he is attacking, as long as he is facing the correct way. I played aroudn with this for quite some time, but i cannot get it to work.
Here is the code I used:
draw actor--
keydown - left
keyup - left
I used the code from http://game-editor.com/forum/viewtopic.php?f=2&t=1655&start=0&st=0&sk=t&sd=a this thread to make myself a walking script. However, I cannot seem to add an attacking feature to it. Can anyone show me what to add and how so that when I press 'L" the player changes to his attack animation. The player can still move while he is attacking, as long as he is facing the correct way. I played aroudn with this for quite some time, but i cannot get it to work.
Here is the code I used:
draw actor--
- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==1) y-=2;
if (key[KEY_DOWN]==1) y+=2;
if (key[KEY_LEFT]==1) x-=2;
if (key[KEY_RIGHT]==1) x+=2;
keydown - left
- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "run_left", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_RIGHT]==1&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==1)
ChangeAnimation("Event Actor", "run_down", FORWARD);
keyup - left
- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_down", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "run_right", FORWARD);