unit g_Base;

interface
uses
  g_Data,g_Types,g_Utils,
  GPAHeader,
  {$INCLUDE uses.inc};

procedure Base_Load(self : zBase; pos : izPosition_f);
procedure Base_Draw(self : zBase);
procedure Base_Update(self : zBase);
implementation

procedure Base_Load(self : zBase; pos : izPosition_f);
var dir : string;
begin
  dir := iz_dir_local_data + 'base.cfg';
  self^.Life := Cfg_ReadInt(dir,'LIFE',1000);
  self^.size[0] := Cfg_ReadInt(dir,'SIZE',256);
  self^.size[1] := self^.size[0];
  self^.Rad := self^.size[0] div 2;
  self^.pos := pos;
  GPAExtractToFileByID(GPAGetIDByName('base.tga',false), 'temp\graphics\base.tga');
  self^.Tex := gfx.TexMan.Load(iz_dir_local_temp_gfx+Cfg_ReadStr(dir,'TEX','base.tga'));
  self^.Spr := gfx.SprMan.Add(gfx.TexMan.GetSize(self^.Tex),World.Base.size);
end;

procedure Base_Draw(self : zBase);
var pos : izPosition_i;
begin
  if ((self^.pos[0]+self^.rad > -Camera.pos[0])and
    (self^.pos[1]+self^.rad > -Camera.pos[1])and
    (self^.pos[0]-self^.rad < -Camera.pos_2[0])and
    (self^.pos[1]-self^.Rad < -Camera.pos_2[1])) then begin
      gfx.TexMan.Bind(self^.Tex);
      pos := zRound(self^.pos);
      gfx.SprMan.Draw_Alpha(self^.Spr,0,self^.Pos,0);
      gfx.FontMan.Write(Game_font,pos,'Life : ' + inttostr(trunc(self^.Life)));
    end;
end;

procedure Base_Update(self : zBase);
begin

end;

end.
