//package pacman;

public class Thingy {
  GameGrid view;
  protected boolean visible = false;
  protected int xPosition = 0, yPosition = 0;
  protected int xMin = 0, xMax = 0, yMin = 0, yMax = 0;
  protected boolean edible = false;
  protected int worth;
  protected String shape;

  public Thingy() {
	  shape = "X";
	  worth = 0;
  }
	public Thingy(String sh, int w) {
		shape = sh;
		worth = w;
	}

  public void setView(GameGrid screen) {
    view = screen;
    if (view != null) {
      xMin = 0; xMax = view.getXSize()-1;
      yMin = 0; yMax = view.getYSize()-1; }
  }

	public boolean isEdible() {
		return edible;	
	}		

	public String getShape () {
		return shape;	
	}		

	public int hasWorth () {
		return worth;	
	}		

	public int getX () {
		return xPosition;	
	}		

	public int getY () {
		return yPosition;	
	}		

  public void makeVisible() {
    visible = true;
    this.draw();
  }

  public void makeInvisible() {
    visible = false;
    this.erase();
  }

  public void erase() {
    if ((view != null) & visible) {
      view.setCellString(xPosition,yPosition," "); }
  }

  public void draw() {
    if ((view != null) & visible) {
      view.setCellString(xPosition, yPosition, shape); }
  }

  public void moveTo(int x, int y) {
    if (view != null) {
       this.erase();};
    if ((x >= xMin) & (x <= xMax)) {
       xPosition = x;};
    if ((y >= yMin) & (y <= yMax)) {
       yPosition = y;};
    if (view != null) {
       this.draw();};
  }

}
