[AS2.0] Creating making enemies dynamic... but I'm an array noob!

Hi guys, I’m trying to tackle a fairly major undertaking (for me anyway) in the form of a game. Development of the game is going fairly well in some departments but I’ve hit a block. I’m pretty unfamiliar with arrays in flash but I have a feeling that it would solve the problem I’m having here. I’ve managed to make a functional enemy that moves towards the player, reacts to his attacks and unloads when it dies.

I’ve also got the animations ready for enemy attacks. The issues is I want to make multiple enemies and not have them occupy the same space. I was thinking the best way to accomplish this would be to put enemy1 and enemy2 into an array and put something along the lines of

if(this.hitTest(_root.enemy[n])){
this._x += 0;
}

Would that be something on the right track? Also in terms of the enemy doing melee attacks, I was wondering if it would be possible to have the character knocked backwards when these attacks hit? I have already attempted it by giving the appropriate properties to an invisible (visible for the sake of demonstrating how it works) hit box that knocks the character back.

Here is a link to the swf

[URL=“https://rapidshare.com/files/299782434/alpha20.fla”]and to the FLA to download

The code for the enemy can be found on frame two on the enemy itself and I’ve commented out the appropriate areas. Again I’m new to this but I’d imagine the key to the movement code and colliding with other enemies would be placed here.

// Combat        if (this._x < _root.char._x)
        {
            if (_root.char._x < ((this._x) + 100))
            {
                this.stances.gotoAndStop("attacking");
            }
            else
            {
                this.stances.gotoAndStop("inCombat");
                this._xscale = 100;
                this._x += 2;
            }
        }
        else if (this._x > _root.char._x)
        {
            if (_root.char._x > ((this._x) - 100))
            {
                this.stances.gotoAndStop("attacking");
            }
            else
            {
                this.stances.gotoAndStop("inCombat");
                this._xscale = -100;
                this._x -= 2;
            }
        }

the code for the character being affected will again be found on frame 2 but on the character respectively. It’s very simple at the moment because I’m not sure how else to put it, but it’s as follows:

    if (damaged)    {
        if(dmgTimer < 5)
        {
            this._x +=2;
            dmgTimer++;
        }
        else
        {
            dmgTimer = 0;
            damaged = false;
        }
    }

This worked on the enemy but obviously that was because there will only ever be one character. Swapping the code round and having multiple enemies makes it way more headache inducing.

Is there anything you guys can do to help? I’m sure it’s probably a really inefficient code or juvenile mistake on my part but I really want to see this game work and it would be horrible if I had to give up because of this. I look forward to working with you guys. :slight_smile:

ooh and to verify how the combat works, the controls are as follows:

Melee:
D - Basic attack
D + (left || right) - basic attack while running
D + UP - Charge upper cut - Release the D key - Completes upper cut

Ranged:
A (while on the ground) - Basic attack. Similar effect when executed in mid air
A + Down (while on the ground) - knocks enemies back in both directions
A + Down (while in the air) - Basic attack shot downwards
A + UP - Basic attack shot upwards

Specials:
S (Hold): Shield
D + Down (while in the air) - large shockwave stun
D + Down (while on the ground) - Knocks enemies back and shoots you in the opposite direction

Devastators:
Note: Both of these attacks can only be performed while the keys D + Down are pressed AND you are no longer moving

Arrow key opposite to the direction you’re facing - Shoots a large high damage projectile

Arrow key that coincides with the direction you’re facing - Charges at your opponent and strikes the first enemy in range.