Page 1 of 1

How do you make fighting moves work?

PostPosted: Sun Sep 02, 2012 6:26 am
by Goomba
hey i need some help with programming some fighting moves for a new game im working on... could someone help me?

Re: How do you make fighting moves work?

PostPosted: Sun Sep 02, 2012 9:14 am
by skydereign
Fighting moves should work like everything else in gE. The only difference is that the actors involved interact via collisions (or similar). That being said, when you change the actor's animation to an attack animation, you'll want to set some variable to signify it is attacking. That way in the collision event, you can tell if the actor is actually attacking, instead of just colliding with a stand animation.

Re: How do you make fighting moves work?

PostPosted: Sun Sep 02, 2012 9:35 pm
by Goomba
i dont understand how i wuold do that.. :(

Re: How do you make fighting moves work?

PostPosted: Sun Sep 02, 2012 11:44 pm
by Fojam
create a variable that says whether the actor is attacking or not. and on a collision event, ask if he's attacking and do what you want to happen

Re: How do you make fighting moves work?

PostPosted: Tue Sep 04, 2012 2:41 am
by Goomba
ahhhhhh.... im getting there i am a complete noob with programming

Re: How do you make fighting moves work?

PostPosted: Tue Sep 04, 2012 7:55 am
by supatails
A few weeks ago I had no clue where to even start with C++ programming and Game-Editor, but Phyziks short series of tutorials (there's only like 4 of them) REALLY helped me try to wrap my mind around some of the basic concepts of coding.
viewtopic.php?f=27&t=11867
And this tutorial by Skydereign was extremely helpful for easing me into the concept of complex actions. I had to reread it a few times but now I have a perfect understanding of it, and can make some relatively complex code!
http://game-editor.com/Switch
If you wanna learn what most of the major functions in GE are, here's a good place to look:
http://game-editor.com/docs/script_reference.htm
Also if you wanna learn what some of the REALLY basic functions are, here's a good simple list:
viewtopic.php?f=27&t=12246
and another:
http://game-editor.com/Variables

skydereign wrote:Fighting moves should work like everything else in gE. The only difference is that the actors involved interact via collisions (or similar). That being said, when you change the actor's animation to an attack animation, you'll want to set some variable to signify it is attacking. That way in the collision event, you can tell if the actor is actually attacking, instead of just colliding with a stand animation.


So basically what he's getting at is you would want to create a variable and name it something, anything you want, in this case we'd name it "attack".
To create your own variable (which is covered in Phyziks tutorial), go to Script>Global Code, and type:
Code: Select all
int attack;

And then type the name at the bottom and press Add.
Pretty simple, now you will want to follow the Switch tutorial I posted, and feel free to reread parts of it until you feel like you fully understand the concept. Believe me, it definitely took me a few tries.

After you've added the Switch(state) cases for all of your players animations/movements, create two cases for state. One for attacking left, and the other for right. Now just have it so if you press the attack button, and state=0, (standing right) or running right (state=2), then you attack facing right. (state=6???) and etc. for the left facing attack. This way, if you want, you can create another attack specifically for when you are jumping. Now that int attack you did earlier comes into use now. Before you put Break;, set attack to 1. It MIGHT look a little something like this:
KeyDown>(Attack Button)(REPEAT DISABLED)>Script Editor:
Code: Select all
switch(state)
{
    case 0: //if you are facing right
    case 2: //or running right
    ChangeAnimation("Event Actor", "Goomba_Right_Attack", FORWARD); //change animation to your attack
    attack=1; //change the attack variable from 0 to 1
    state=6; //set state to 6, which in this situation means your player is attacking to the right
    break; //execute the code
}

and then on your KeyUp>(Attack Button)>Script Editor:
Code: Select all
switch(state)
{
    case 6: //if you are attacking to the right
    ChangeAnimation("Event Actor", "goomba_right_idle", NO_CHANGE); //change to the idle animation
    state=0; //change your state back to standing facing right
    attack=0; //set attack to 0, which means you're not attacking
    break; //execute the code
}


and lastly, make a collision event with the enemy you're attacking; if attack=1 and you're colliding with the enemy, the enemy will lose health (you can do this by giving the enemy a variable for health, like "int enemyhealth", setting enemyhealth to a number, like 100, and then subtract from it, like subtract 25 everytime you hit the enemy, and if enemyhealth<=0, destroyActor.

I really hope this helped lead you in the right direction. I know firsthand how frustrating it is having the passion for game-design but no-one around to help you, so I'll gladly try to teach you what little I know whenever possible. Good luck! :mrgreen:

Re: How do you make fighting moves work?

PostPosted: Wed Sep 05, 2012 3:22 am
by Goomba
yus thanx for all the reference this'll help a lot :mrgreen: 8) :D thanx

Re: How do you make fighting moves work?

PostPosted: Wed Sep 05, 2012 4:18 am
by supatails
Glad I could help! :mrgreen: