Some "simple" codes needed

Non-platform specific questions.

Some "simple" codes needed

Postby Wayra Condor » Mon Feb 09, 2009 2:59 am

I'm trying to make a fighting game, I had this proyect long ago, but I got borred because making images on paint is damm hard, so I forgot almost all on coding without bugs, so if someone could please post here codes to make actors:

.-jump only once, and run an animation before it jumps, while it is on air and when it falls
.-walk on a floor, and make this floor solid
.-make a good life bar
.-make actors take damage while an attack it excecuted on them, but certain amount depending on the attack
.-make actors have an animation while they are taking damage
.-make actors have an animation to send they flying if the damage if too huge or after excecuting certain attack
.-make a timer to stop the fight if the time passed

I only need those codes by the time, when I have them I'll try to make a demo to show my proyect

Thanks :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: Some "simple" codes needed

Postby skydereign » Mon Feb 09, 2009 4:42 am

Do you know how to use variables? This is mostly variable use. This will be an easy way so it is easily understood. It is possible to improve these later. It actually would be better to, but first you need to understand the concept, then develop from that... Unless you know coding already.

.-jump only once, and run an animation before it jumps, while it is on air and when it falls
Create a variable called jump. Upon collision with the ground, set jump to 1. Add a key down event for your jump event. If the actor has jump, then jump. Also add a change animation. Upon the end of the jumpstart animation add another event that changes animation. I am not sure what you mean by end, if you just mean on the actor's decent or falling, if yvelocity>3 or some number, do not put it at zero, as it will mess with normal animations, change the animation (this is draw actor event)

.-walk on a floor, and make this floor solid
I tend to make movement in draw actor. You could also use individual keydown events.
Actor->DrawActor->Script Editor
Code: Select all
char* key=GetKeyState(); // allows key use
if (key[KEY_RIGHT]==1)
{
    x+=10;
    // you will need a direction variable or use the angle/direction variable built in, this will allow the actor to choose which
    // set of animations to use
    // your change animation, this method can become a problem if you want anti-moonwalking help just ask
}
// and another one for left, changing the direction and other

Also, you need to land, so create an event upon collision with ground (enable repeat), and set it to physical response (the bottom two should be set to 0)

.-make a good life bar
There are many methods for this. You can make a text one or an animation. I would make an animation. Create an vertical image that looks like this,
_______

[]
[][]
[][][]
_______
Upon the creation of this actor (health bar), set the animation to stop
Health Bar->DrawActor->Script Editor
Code: Select all
animpos=HP;


.-make actors take damage while an attack it executed on them, but certain amount depending on the attack
Upon the attack button down, you can set a variable to make an attack, you can also set the damage it will deal and other 'stats' about the attack
So on the enemy's collision with your main actor, it would have an attack, one way of attack, just use certain attacks for certain variables
Code: Select all
switch (attack)
{
    case 1:
    EnemyHP-=10; // 10 is the damage, if you are using a damage variable determined by the attack then you can switch the 10 to damage.
                           // Using an array for health makes creating many actors easier, I can explain in depth if you want
    // You would also want to add a knock back, if the attack is right or if a certain variable is triggered
    // Also a ChangeAnimation
    break;
    case 2:
    // Similar to the previous
}


.-make actors have an animation while they are taking damage
Answered above

.-make actors have an animation to send they flying if the damage if too huge or after excecuting certain attack
Answered above ( You can set a conditional there such as,
Code: Select all
if (damage>10)
{
    //knock back, ChangeAnimation
}


.-make a timer to stop the fight if the time passed
Set a count down? Have an actor that is a text actor
In its creation event, make a variable for the given time
In its draw actor
Code: Select all
textNumber=countdown;
countdown--;


Any questions, just ask. These may be flawed depending on how you set everything up...
Also you will need a way of sorting animation priority, so your events can't overide other events. If you need help on this I think this topic covers it well enough... http://game-editor.com/forum/viewtopic.php?f=5&t=6465
It has it 'built in'. Also it will allow you to do combos, if you want that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Some "simple" codes needed

Postby Wayra Condor » Wed Feb 11, 2009 3:48 am

ehhhh... I got a bit confused about the live bar...

Can you put step by step how to create it in order to make it work well and to run an animation when the character dies and then resurrect it for the next round?
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: Some "simple" codes needed

Postby skydereign » Wed Feb 11, 2009 4:35 am

Okay, you need to start by creating the image. It should increment up from 0 life to however many steps you want. Like the attachment. This way the animpos can be directely altered by HP. Now, you need to create an actor, and give it the animation.
CreateActor->Script Editor // At this point you will need a variable for HP, if you are going to have multiple enemies fight you at once than I suggest using an array
Code: Select all
HP=3; // Since the highest health bar animation is 3 bars, it will be the max
ChangeAnimationDirection("Event Actor", STOPPED); // Stops the animation

Now in the DrawActor event, you need to make the animpos equal to the health, that way if the health goes down, so does the animation.
DrawActor->Script Editor
Code: Select all
animpos=HP; // This way, 0 HP is animpos 0, 3 is animpos 3


Do you mean the health or the player runs the animation? Either way, you would put it into that actor's draw script.
Player or HealthBar->DrawActor->Script Editor
Code: Select all
if (HP==0) // You should probably make this if (HP<=0) because if you deal excess damage it won't kill them
{
    //Change to the Animation
}

Now you would need a variable to signify if there is a next round. I am going to assume there are three rounds, so each battle this will decrement. So upon defeat, the if HP<=0, also add the event
Code: Select all
rounds--;

Then if the rounds are equal to zero then run the death animation, but if it is greater than 0, run the resurrect animation, if I get what you are asking.
Code: Select all
if (HP<=0)
{
    rounds--; // This needs to be before, as it reads the events, this will decrement before checking for which animation to display
    if (rounds>0)
    {
        //Change the animation to ressurect
    }
    else
    {
        //Change the animation to death
    }
}
}
Attachments
hp.png
hp.png (263 Bytes) Viewed 592 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron