Page 1 of 1

multiple animation

PostPosted: Mon Sep 11, 2006 8:17 pm
by EvilAlex
Hi i'm trying to create two animations in the same key down; one when facing right and one facing left. I got a runing demo if i can work this out. Yes i'm a noob but at least i got a book on C. I could do so much if i can do something like this work. Here what i try. simon is the event actor.



char *key = GetKeyState(); //Get entire keyboard state
int facing = 0; //Determines facing, 1 = right ; 2 = left ; 3 = up ; 4 = down.
int moving = 0;

if(key[KEY_DOWN] == 1) //down key is pressed
{
x = x + 0; //stop actor
}
if(key[KEY_DOWN] == 1 && facing == 1) //if he looks to the right
{
ChangeAnimation("simon", "kneeR", FORWARD);
}
if(key[KEY_DOWN] == 1 && facing == 2) //if he looks to the left
{
ChangeAnimation("simon", "kneeL", FORWARD);
}


I thought this was the best way with the facing state but i think it is missing code, maybe i have to give state to each key.I search for hours in tutorials and the forums, sorry if i miss something. I try alot of thing that i found but nothing seem to solve my problem. It a castlevania (In 2007 SOTN will be 10 years old) type of game and game editor is really great. I did great monsters behavior but now i realise that i have to learn C.

Thanks for any reply.

EvilAlex

PostPosted: Mon Sep 11, 2006 10:54 pm
by Novice
I think that you are missing an else if statement in there and that you shouldn't declare the "facing" varible here, you should make it a global variable. Because if you are asigning facing from somwhere else in the script it won't work.
Code: Select all
char *key = GetKeyState(); //Get entire keyboard state
int moving = 0;

if(key[KEY_DOWN] == 1) //down key is pressed
{
x = x + 0; //stop actor
}
if(key[KEY_DOWN] == 1 && facing == 1) //if he looks to the right
{
ChangeAnimation("simon", "kneeR", FORWARD);
}
else if(key[KEY_DOWN] == 1 && facing == 2) //if he looks to the left
{
ChangeAnimation("simon", "kneeL", FORWARD);
}

PostPosted: Tue Sep 12, 2006 3:15 pm
by EvilAlex
thanks, i think i'm getting on the right tracks now. what i'm trying to do is getting facing varible working so i can make my player attack, jump, knee,knee atk facing the current side. if i stop facing right i want to use the right animation of all above. Should i use if animation equal rightstand.gif and key down equal 1 change animation to rightknee.gif.

Also if i use global script can i have a conflict with keydown edit script.

thank for your quick reply


EvilAlex