How do you make fighting moves work?

Non-platform specific questions.

How do you make fighting moves work?

Postby Goomba » Sun Sep 02, 2012 6:26 am

hey i need some help with programming some fighting moves for a new game im working on... could someone help me?
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: How do you make fighting moves work?

Postby skydereign » Sun Sep 02, 2012 9:14 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do you make fighting moves work?

Postby Goomba » Sun Sep 02, 2012 9:35 pm

i dont understand how i wuold do that.. :(
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: How do you make fighting moves work?

Postby Fojam » Sun Sep 02, 2012 11:44 pm

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
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: How do you make fighting moves work?

Postby Goomba » Tue Sep 04, 2012 2:41 am

ahhhhhh.... im getting there i am a complete noob with programming
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: How do you make fighting moves work?

Postby supatails » Tue Sep 04, 2012 7:55 am

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:
User avatar
supatails
 
Posts: 43
Joined: Tue Aug 04, 2009 4:54 am
Score: 1 Give a positive score

Re: How do you make fighting moves work?

Postby Goomba » Wed Sep 05, 2012 3:22 am

yus thanx for all the reference this'll help a lot :mrgreen: 8) :D thanx
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: How do you make fighting moves work?

Postby supatails » Wed Sep 05, 2012 4:18 am

Glad I could help! :mrgreen:
User avatar
supatails
 
Posts: 43
Joined: Tue Aug 04, 2009 4:54 am
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron