/*
 * Entity.java
 *
 * Created on 04 janvier 2005, 16:46
 */

package hyperion;
import java.applet.*;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Image;
/**
 *
 * @author CryoGen
 */


public class Entity extends Object{
    protected Image image;  //image de l'entit้
    protected Animation anime;
    protected boolean visible; // visible ou pas , facile hein ?
    protected int offset_x, offset_y;
    public int _x , _y;  //position (x,y) de l'entit้
    protected int height, width; //taille du rectangle de capture image
    
    protected int type; //type
    protected int stype; //sous-type
    
    public int speed_x, speed_y;
    protected int APPLET_H, APPLET_W;
    protected Applet applet;
    
    public long delay;
    
    public int getType() { return type; }
    public int getStype() { return stype; }
    
    public void setVisible(boolean set) {
        this.visible = set;
    }
    
    public void move_x(int speed) {
        this._x += speed; 
    }
    
    public boolean move_y(int speed) {
        this._y += speed;
        if(this._y > 480)
            return false;
        return true;
    }
    
    public void setSpeed(int sx, int sy){
        this.speed_y = sy;
        this.speed_x = sx;
    }
    
    public int getX() { return _x; };
    public int getY() { return _y; };
    

    public boolean collision(Entity entity) {
        boolean collision = false;
        
        //coin NE vaisseau dans it ?
        if(_x <= (entity._x + entity.width) && _x >= entity._x && _y <= (entity._y + entity.height) && _y >= entity._y)
        {
            collision = true;
        }
        //coin NO vaiseau dans it ?
        if(_x+width <= (entity._x + entity.width) && _x+width >= entity._x && _y <= (entity._y + entity.height) && _y >= entity._y)
        {
            collision = true;
        }
        
        //coin SO ....
        if(_x+width <= (entity._x + entity.width) && _x+width >= entity._x && _y+height <= (entity._y + entity.height) && _y+height >= entity._y)
        {
            collision = true;
        }
        
        //coin SE ....
        if(_x <= (entity._x + entity.width) && _x >= entity._x && _y+height <= (entity._y + entity.height) && _y+height >= entity._y)
        {
            collision = true;
        }
        
        return collision;
    }

    
    public void draw(Graphics g) {
        anime.draw(g, _x, _y);
    }
};

