Weapons

Game Editor comments and discussion.

Weapons

Postby Phil » Thu Apr 06, 2006 4:02 pm

OK I want to make a 2 handed sword!How can I
HELP!
Phil
 
Posts: 4
Joined: Tue Mar 21, 2006 3:38 pm
Location: Bulgaria
Score: 0 Give a positive score

Postby DilloDude » Fri Apr 07, 2006 12:34 am

Making swords is fairly simple, but not easy to do well. First, a simple function; add this in global code:
Code: Select all
void ASBS(char *ANAME, int animation_direction)
{
    if (animindex != getAnimIndex(ANAME))
    {
        ChangeAnimation("Event Actor", ANAME, animation_direction);
    }
}

ASBS stands for animation should be string. All it does is change animation, but only if that animation is not already playing.
You'll want two actors, a 'player' and a 'sword'. Make two variables: 'swing' and 'dir'. Add keydown events on your player to move him and change dir to the direction of his movement. Add on keydown->sword: swing = 1; Your sword should have animations for being still in all directions and swinging in all directions. For this example, lets just use 1 for right and -1 for left. So your sword has 4 animations: left, right, swingleft, swingright. On draw actor->sword:
Code: Select all
x=Player.x;
y=Player.y;
if (dir==1)
{
    if (swing==0)
    {
        ASBS("right", FORWARD);
    }
    else
    {
        ASBS("swingright", FORWARD);
    }
}
else
{
    if (swing==0)
    {
        ASBS("left", FORWARD);
    }
    else
    {
        ASBS("swingleft", FORWARD);
    }
}

on animation finish-> sword, swing = 0;

on collision->enemy->any side of sword
Code: Select all
if (swing)
{
    DestroyActor("Event Actor");
}

To make the animations better, Have player animations for swinging to make it look like he is swinging the sword.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest