I having some problems with code, I need to set up a variable called direct and attached that to the "GetKeyState" function to make my character shoot 4 ways.
I using the following code, but It's not working.
- Code: Select all
int direct;
char*key=GetKeyState();
if(key[KEY_LEFT] == 1)direct = 0;
if(key[KEY_RIGHT] == 1)direct = 1;
if(key[KEY_UP] == 1)direct = 2;
if(key[KEY_DOWN] == 1)direct = 3;
then in my bullet actor
- Code: Select all
if(direct==0) // left
{CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->xvelocity=-10;}
if(direct==1) // right
{CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->xvelocity=10;}
if(direct==2) // up
{CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->yvelocity=-10;}
if(direct==3) // down
{CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->yvelocity=10;}
What am I doing something wrong?
Thanks for any help
Johnno
PS. added my game files