// vim:syntax=javascript

class Explosion extends Actor
{
    static var BLAST_RADIUS : Number = 50;
    static var sprite_names : Array = ["explosion"];
    static var EXPLOSION_SIZE : Number = 100;
    static var EXPLOSION_FRAMES : Number = 10;

    var _frames_left : Number;

    function Explosion(parent_mc : LevelClip, px : Number, py : Number) {
        super(parent_mc, sprite_names, px, py, Actor.DIR_UP, EXPLOSION_SIZE);

        _frames_left = EXPLOSION_FRAMES;
    }

    function doFrame() {
        get_parent_mc().doActorsInRadius(this, Explosion.BLAST_RADIUS,
            function (a : Actor) {
                if (a.canBeKilled()) {
                    a.setDead();
                }
            });

        // only on first frame should we bother breaking walls
        if (_frames_left == EXPLOSION_FRAMES) {
            get_parent_mc().clearBlocksInRadius(
                x+EXPLOSION_SIZE/2, y+EXPLOSION_SIZE/2, BLAST_RADIUS);
        }

        _frames_left --;
        if (_frames_left < 0) {
            setDead();
        }
    }
}
