multiple animation

Non-platform specific questions.

multiple animation

Postby EvilAlex » Mon Sep 11, 2006 8:17 pm

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
EvilAlex
 
Posts: 5
Joined: Sun Sep 10, 2006 2:56 am
Score: 0 Give a positive score

Postby Novice » Mon Sep 11, 2006 10:54 pm

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);
}
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby EvilAlex » Tue Sep 12, 2006 3:15 pm

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
EvilAlex
 
Posts: 5
Joined: Sun Sep 10, 2006 2:56 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest