
abstract class PixelSprite {
  protected PixelSpriteComposite parent;

  protected double x, y; // relative to 'parent'
  protected boolean visible;

  public PixelSprite() {
    this.parent = null;

    this.x = 0;
    this.y = 0;

    setVisible( true );
  }

  public void setParent( PixelSpriteComposite parent ) {
    this.parent = parent;
  }

  /*
   * setting location
   */
  public double getX() {
    return x;
  }

  public void setX( double x ) {
    this.x = x;
  }

  public double getY() {
    return y;
  }

  public void setY( double y ) {
    this.y = y;
  }

  public void setLocation( double x, double y ) {
    setX( x );
    setY( x );
  }

  /*
   * moving location
   */
  public void moveX( double deltaX ) {
    this.x += deltaX;
  }

  public void moveY( double deltaY ) {
    this.y += deltaY;
  }

  public void move( double deltaX, double deltaY ) {
    moveX( deltaX );
    moveY( deltaY );
  }

  /*
   * visability
   */
  public void setVisible( boolean visible ) {
    this.visible = visible;
  }

  public boolean isVisible() {
    return visible;
  }

  /*
   * rendering
   */
  public final void render( PixelPanel panel, double parentX, double parentY ) {
    if ( visible ) 
      renderHook( panel, parentX, parentY );
  }

  protected abstract void renderHook( PixelPanel panel, double parentX, double parentY );
}
