/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

***********************************************************************/

package gecco.client.animation;
import gecco.client.*;

import java.awt.*;

/**
 *  An explosion is an animated piece that has a finite animation of an
 *  explosion. The class depends on some gif images in the icons catalog.
 *
 * @author     Andreas Enblom
 * @created    June 27, 2001
 */
public class Explosion extends AnimatedPiece {
    /**
     *  The frames of the explosion.
     */
    static Image[] explosionFrames;


    /**
     * @param  handle    The piece handle.
     * @param  position  The piece postion.
     * @param  name      The piece name.
     * @param  type      The piece type. Note that this does not affect the
     *      symbols used.
     * @param  animator  The aniomator that animates this piece.
     */
    public Explosion(int handle, Position position, String name,
            String type, Animator animator) {
        super(handle, position, name, type, explosionFrames, 100,
                false, animator);
    }

    static {
        Toolkit tk = Toolkit.getDefaultToolkit();
        ClassLoader scl = ClassLoader.getSystemClassLoader();
        Image frame1 =
                tk.createImage(scl.getResource("client/icons/explosion1.gif"));
        Image frame2 =
                tk.createImage(scl.getResource("client/icons/explosion2.gif"));
        Image frame3 =
                tk.createImage(scl.getResource("client/icons/explosion3.gif"));
        Image frame4 =
                tk.createImage(scl.getResource("client/icons/explosion4.gif"));
        MediaTracker mt = new MediaTracker(null);
        mt.addImage(frame1, 1);
        mt.addImage(frame2, 2);
        mt.addImage(frame3, 3);
        mt.addImage(frame4, 4);
        try {
            mt.waitForAll();
        } catch (Exception ex) {
        }
        Image[] frames = {frame3, frame4, frame3, frame2, frame1};
        explosionFrames = frames;
    }
}
