Page 1 of 2

help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 1:40 pm
by DarkParadox
Hello, i need help on this code and i don't know how to fix it but i just can't do it :cry:

Code: Select all
char *key = GetKeyState();
if(key[KEY_LEFT] == 1)
{
if(switchdiretion==1)
{
    ChangeAnimation("Event Actor", "right-to-left", FORWARD);
    switchdiretion=-1;
    anifinishright=0;
}
if(anifinishright==1)
{
x = x - 2;
}
}
if(key[KEY_RIGHT] == 1)
{
if(switchdiretion==-1)
{
    ChangeAnimation("Event Actor", "left-to-right", FORWARD);
    switchdiretion=1;
    anifinishleft=0;
}
if(anifinishleft==1)
{
x = x + 2;
}
}




Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:13 pm
by DarkParadox
come on, please help me :cry:

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:15 pm
by Bee-Ant
Why you dont use KeyDownEvent???I'm not tried it yet

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:19 pm
by DarkParadox
no, but should i?

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:24 pm
by DarkParadox
everything is working exept for the fact that he's not moving left or right

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:26 pm
by Bee-Ant
just try it with Keydown event...there're many ways to do something, just try it one by one and choose the best one :D
Ummm...have you added
Code: Select all
x=x-3;

in keydown LEFT, and
Code: Select all
x=x+3;

in keydown RIGHT

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:29 pm
by DarkParadox
i put x = x +2;
but does it make that much of a diffrence
'

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:32 pm
by Bee-Ant
I think not... :D
Btw, make sure if that keydown event to move, which have x=x-2; inside is repeated :D

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:35 pm
by DarkParadox
i did i just not working either

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:40 pm
by DarkParadox
Wait i found my error and fixed it
thank for trying to help, +1 point
for your troubles :D :D

Re: help on code, whats wrong with it?

PostPosted: Sat Dec 15, 2007 2:45 pm
by Bee-Ant
I dont think if made troubles...
KeyDown>Left>ScriptEditor>
Code: Select all
x=x-3;

KeyDown>Right>ScriptEditor>
Code: Select all
x=x+3;

It should work fine :wink:
Btw, I'm not attracted with score... :roll:
THANKS anyway :oops:

Re: help on code, whats wrong with it?

PostPosted: Sun Dec 16, 2007 12:21 am
by Game A Gogo
Make sure that "anifinishright" or "anifinishleft" are equal to one when pressing the keys, try to change it so it checks if the value is 0 instead, you could do trouble shooting from there

Re: help on code, whats wrong with it?

PostPosted: Sun Dec 16, 2007 6:39 am
by Bee-Ant
nice analysis :D

Re: help on code, whats wrong with it?

PostPosted: Mon Dec 17, 2007 12:34 am
by Game A Gogo
I use that technique a lot

Re: help on code, whats wrong with it?

PostPosted: Mon Dec 17, 2007 4:58 am
by Bee-Ant
Yeah I see...because you're senior here :roll: