// vim:syntax=javascript

class SpinyEnemy extends Enemy
{
    static var ENEMY_SIZE : Number = 20;
    static var ENEMY_SPEED : Number = 2;
    static var sprite_names : Array = ["spikey_up","spikey_left","spikey_down","spikey_right"];
    var _turn_around_type : Array;

    function SpinyEnemy(parent_mc : LevelClip, ei : EnemyInit) {
        super(parent_mc, sprite_names, ei.pos.x, ei.pos.y, ei.dir, ENEMY_SIZE);

        _turn_around_type = DIR_OPPOSITE;
    }

    // TODO: the straightforward motion modes might be best in the superclass
    function doFrame() {
        var dp = dir_point;
        var next_x = x+dp.x*ENEMY_SPEED;
        var next_y = y+dp.y*ENEMY_SPEED;

        if (get_parent_mc().checkActorCollision(this, get_parent_mc()._guy)) {
            get_parent_mc()._guy.setDead();
        }
        if (canMoveTo(next_x, next_y)) {
            moveTo(next_x, next_y, dir);
        } else {
            moveTo(x,y, _turn_around_type[dir]);
        }
    }
}
