Page 1 of 1

Character crouch, jump, walk... for the corect side. Help!

PostPosted: Fri Jul 15, 2005 8:00 pm
by Chapolin
Hi guys! I try to make a game with GE based on Ninja Gaiden style, and have a doubt with KeyDown and KeyUp events.

Well, I have a character with all animations and sprites, and either he is able to walk, jump and crouch. With exception of walk, the rest of the movements is activated depending of the last direction of the animation (in other words, depend of the last sprite/animation of the character on the screen). So, if he look at the left, when I press the down arrow he crouch with the animation/sprite to left. Understand me? How make this? Something like this:

if (char_stopright)
{
ChangeAnimation ("player_char", "crouch_left", FORWARD);
}

??? Not work (not in my hands...)! :(

Puleeeez, help me! :cry:

I think this explanation is very important for everybody making platform games. Thaks for some help. And sorry, my english is terrible... :roll:

Sorry

PostPosted: Fri Jul 15, 2005 8:05 pm
by Chapolin
Sorry, I wanted to say "if (char_stopleft)..." Oh, it is just an example. :oops:

PostPosted: Sat Jul 16, 2005 12:05 am
by BeyondtheTech
Create a global variable that will store the direction, based on the last key that was pressed.

i.e. 1 = left, 2 = right, 3 = up, 4 = down (if the last two are necessary)

That way, when you refer back to that variable, you'll know which animation to pick.

PostPosted: Sat Jul 16, 2005 5:33 pm
by CdaMarinersFan
You can even do it the easy way and make "KeyDown" Events for each action, then use action "Change Animation" for each little thing you want your character to do.

PostPosted: Sun Jul 17, 2005 8:35 pm
by Chapolin
Very thank you, people! :D I go to try this immediately! I will try to make a mini-game with only one stage contend some characteristics of a platform style game. I wait that it is a good example of tutorial or demo for people who are starting in the creation of this type of game.

One more time: Thank you! :wink:

PostPosted: Tue Jul 19, 2005 1:31 pm
by Chapolin
Well, I have followed the help of you guys and a script tutorial in the GE Help menu updated and tried things like this for the jump movement:


int key = getLastKey();

if(lastKey = KEY_LEFT)
{
ChangeAnimation("player", "jump_left", FORWARD);
}

if(lastKey = KEY_RIGHT)
{
ChangeAnimation("player", "jump_right", FORWARD);
}

last:Key = key


But not work correctly. Just for one of the sides (only left or only right). This is a bug (well... I'm a bug, but... he)? Or the functions are in conflict because of the use of the same key (the "KEY_UP" in KeyDown event>up)? When I remove one of the lines...:


if(lastKey = KEY_LEFT)
{
ChangeAnimation("player", "jump_left", FORWARD);
}


... the other works correctly.

And what the diference between "=" and "==" in the script? "==" is for a persistent order or something like this? When I put "==" in the script you look, he not works!

For last, have somebody a platform game demo with a script simmilar to this, for example? The tutorial in the GE is too simple, although I have get more skill in GE with then (thanks for the author!).

PostPosted: Tue Jul 19, 2005 4:22 pm
by BeyondtheTech
== is a equal test.
!= is not equal test.