/*
 * Alien.java
 *
 * Created on 29 décembre 2004, 18:17
 */

package hyperion;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Image;
/**
 *
 * @author CryoGen
 */
public class Alien {
    static int sens = 1; //var de class
    static int count = 0;
    
    private int _x;
    private int _y;
    private boolean visible;
    
    private Image image;
    private int offset_x;
    private int offset_y;
    private int height, width;
    
    
    /** Creates a new instance of Alien */
    public Alien(int x, int y, Image img) {
        _x = x;
        _y = y;
        visible = true;
    }
    
    public void move(int speed) {
        _x += speed*sens;
        count++; //var de class
        if(count == (40/speed)*20)
        {
            count = 0;
            sens *= -1;
        }
    }
    
  //  public Projectile generateProjectile() {
  //      Projectile p = new Projectile(_x, _y);
  //      return p;
   // }
    
    public void drawAlien(Graphics g) {
        if(visible){
            g.setColor(Color.GREEN);
            int [] x_poly = { _x, _x+5, _x+10, _x+10, _x+3,  _x+1, 
                    _x-1, _x-3, _x-10, _x-10, _x-5};
            int [] y_poly = { _y, _y-5, _y-5,  _y-15, _y-15, _y-8,
                    _y-8, _y-15, _y-15, _y-5, _y-5};
            g.fillPolygon(x_poly, y_poly, 11);
        }
    }
    
    public boolean collisionAlien(int Mx, int My) {

        return false;
    }
    
    public void setVisible(boolean vis) {
        visible = vis;
    }
    
    private boolean borne(int n1, int n2, int M) {
        int nT;
        if(n2 < n1)
        {
            nT = n2;
            n2 = n1;
            n1 = nT;
        }
        if(n1 <= M && M <= n2) return true;
        else return false;
    }
}
