/*
 * Projectile.java
 *
 * Created on 29 décembre 2004, 16:47
 */

package hyperion;

import java.applet.*;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Image;

/**
 *
 * @author CryoGen
 */
public class Projectile extends Entity{

    static public Image imgProj;
    
    //private int _x;
    //private int _y;
   
    private int puissance;
    private int offset_y;
    //private Image image;
    private int pos_img;
    private float pos_imgf;
    
    private Applet applet;
    
    /** Creates a new instance of Projectile */
    public Projectile(int x, int y, int type, Applet applet) {
        this._x = x;
        this._y = y;
        this.height = 16;
        this.width = 16;
        this.applet = applet;
        
        this.type = type;
        switch(type)
        {
            case 0:
                this.puissance = 2;
                this.offset_y = 0;
                break;
            case Item.WEAPON_TYPE_1:
                this.puissance = 5;
                this.offset_y = 1;
                break;
            case Item.WEAPON_TYPE_2:
                this.puissance = 10;
                this.offset_y = 2;
                break;
            default:break;
        }
    }
    
    public int getY() { return _y; }
    public int getX() { return _x; }
    
    public void moveProjectile(int speed) { _y += speed; }
    public int getPuissance() { return this.puissance; }
    
    public Explosion generateExplosion() {
        return new Explosion(_x+(this.height/2), _y, type, applet);
    }
    
    public void drawProjectile(Graphics g) {
        if(this.pos_img == 1) this.pos_img = 0;
        else this.pos_img = 1;
        
        int dx1 = this._x - 8;
        int dy1 = this._y - 8;
        int dx2 = dx1 + 20;
        int dy2 = dy1 + 22;
        
        int sx1 = this.pos_img*20;
        int sy1 = this.offset_y*22;
        int sx2 = sx1 + 20;
        int sy2 = sy1 + 22;
        
        
        g.drawImage(imgProj, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, this.applet);
    }
}
