package Naves2;

import java.awt.Graphics;
import javax.swing.ImageIcon;

class Nave {
    private int x, y;
    private ImageIcon Img;
    private String path = 
    "/Users/felix/fie_mac/public_html/programacion_java/codigos/Capitulo_8/Naves2/";
    
    public Nave() {
        x = 40;
        y = 40;
        Img = new ImageIcon(path+"nave.jpg");
    }
    
    public int getX() {
        return x;
    }
    
    public int getY() {
        return y;
    }
    
    public void dibuja(Graphics g) {
        g.drawImage(Img.getImage(), x-25, y-25, 50, 50, null);
    }   
    
    public void mueve(int dx, int dy) {
        x = x+dx  >   0 ? x+dx : 400;
        x = x+dx  < 400 ? x+dx : 0;
        y = y+dy  >   0 ? y+dy : 400;
        y = y+dy  < 400 ? y+dy : 0;
    }     
}
