{
  Stuff, that's lying around
}

unit uGameObject;

interface

uses 
  ElysionLegacy,
  uBasic;

type
TGameObject = class(TelObject)
private
  FSprite, FSpriteShadow: TelSprite;
  
public
  Position: TelPoint;

  constructor Create;
  destructor Destroy; Override;
  procedure Free;
  
  procedure Draw;
  
  procedure SetGridPos(Point: TelPoint);
end;

implementation

constructor TGameObject.Create;
var ClipY: Integer;
begin
  FSprite := TelSprite.Create;
  FSpriteShadow := TelSprite.Create;
  
  ClipY := 0;
  FSprite.LoadFromFile(GetResImgPath + 'objects.png', makeRect(0, ClipY, GRID_SIZE, GRID_SIZE));
  FSprite.Transparent := true;
  FSprite.Generate(gmRGB);
  
  FSpriteShadow.VirtualClone(FSprite);
  FSpriteShadow.ClipImage(makeRect(GRID_SIZE, ClipY, GRID_SIZE, GRID_SIZE));
end;

destructor TGameObject.Destroy;
begin
  if Self <> Nil then Free;
end;

procedure TGameObject.Free;
begin
  FSprite.Free;
  FSpriteShadow.Free;
end;

procedure TGameObject.Draw;
begin
  FSprite.Position := Position;
  FSpriteShadow.Position := Position;

  FSpriteShadow.Draw;
  FSprite.Draw;
end;

procedure TGameObject.SetGridPos(Point: TelPoint);
begin
  Position.X := Point.X * GRID_SIZE;
  Position.Y := Point.Y * GRID_SIZE + TOP_MENU;
end;


end.