unit uGlobal;

{$mode delphi}

interface

uses
  Classes, SysUtils, zglHeader, uMeSprite, uSiluet, uMeForm;

var

  TileAtlas, cube, mFGame, mGui,
  Atlas : zglPTexture;

  sFig   : array[1..7] of TMeSprite;
  sFig_p : array[1..6] of TMeSprite;
  sFig_f : array[1..6] of TMeSprite;

  sGui, sGuiE : array[1..4] of TMeSprite;

  sgui_live, sgui_live_e,
  sgui_sh, sgui_sh_e,
  sgui_sword, sgui_sword_e, sgui_sword_en,
  sgui_mana, sgui_mana_e,
  sgui_exp, sgui_exp_e,
  sgui_heart, sgui_heart_e
  : TMeSprite;

  Scr1, Scr2,
  sTiles : TMeSprite;
  mFont : zglPFont;
  Siluet : array[1..7] of TSiluet;

  BtnClose_Shape : TShapeRect;
  BtnClose_DrawRect : TMeFormDrawRect;
const
  WinW = 1280;
  WinH = 800;

  cRectSize = 54;

  cAngleX : array[0..3] of Integer = (1, 0, -1,  0);
  cAngleY : array[0..3] of Integer = (0, 1,  0, -1);
  cEnemyTimer = 150;

  cPortal = 11;
procedure LoadTextures;

implementation

procedure LoadTextures;
var
  I, J, K, Y, S1, S2, S3 : Integer;
  srcSiluet : TSiluet;
begin
  Atlas := tex_LoadFromFile('data\panel_r.png');

  BtnClose_DrawRect := TMeFormDrawRect.Create(Atlas, 180, 52);
  BtnClose_DrawRect.Add(0, 107);
  BtnClose_DrawRect.Add(0, 107 + 1 * 52);
  BtnClose_DrawRect.Add(0, 107 + 2 * 52);
  BtnClose_DrawRect.Add(0, 107 + 3 * 52);
  BtnClose_Shape := TShapeRect.Create(162, 30);

  mFont := font_LoadFromFile('data\font_1.zfi');
  TileAtlas := tex_LoadFromFile('data\tiles.png');
  mFGame := tex_LoadFromFile('data\FG.png');

  Scr1 := TMeSprite.Create(tex_LoadFromFile('data\scr1.png'), 1024, 512);
  Scr1.Add(0, 0);

  Scr2 := TMeSprite.Create(tex_LoadFromFile('data\scr2.png'), 512, 128);
  Scr2.Add(0, 0);

  sTiles := TMeSprite.Create(TileAtlas, 70, 80);
  sTiles.Add(0, 0);
  sTiles.Add(0, 80);
  for I := 1 to 6 do
  sTiles.Add(I * 70, 0, 70, 160);
  sTiles.Add(4 * 70, 160);
  sTiles.Add(3 * 70, 160);

  sTiles.Add(0 * 70, 160);
  sTiles.Add(1 * 70, 160);


  for I := 1 to 7 do
  begin
    sFig[I] := TMeSprite.Create(mFGame, 50, 50);
    sFig[I].Add(I * 50 - 50, 50);
    sFig[I].Add(I * 50 - 50, 0);
  end;

  for I := 1 to 5 do
    sFig[I].Add(I * 50 - 50, 172);

  sFig[6].Add(50, 172);
  sFig[7].Add(6 * 50, 0);

  S1 := 36;
  S2 := 18;
  S3 := 9;

  for I := 1 to 6 do
  begin
    sFig_p[I] := TMeSprite.Create(mFGame, 32, 32);
    sFig_p[I].Add(I * 32 - 32, 512 - 32*3);
    sFig_p[I].Add(I * 32 - 32, 512 - 32*3);
    sFig_p[I].Add(I * 32 - 32, 512 - 32*3);


    sFig_f[I] := TMeSprite.Create(mFGame, S2, S3);
   { for J := 0 to 3 do
    begin
      sFig_f[I].Add(I * 50 - 50, 100 + J * 50);
      sFig_f[I].Add(I * 50 - 25, 100 + J * 50);
      sFig_f[I].Add(I * 50 - 50, 125 + J * 50);
      sFig_f[I].Add(I * 50 - 25, 125 + J * 50);
    end;  }

     for J := 0 to 1 do
     for K := 0 to 1 do
     for Y := 0 to 3 do
     begin
       sFig_f[I].Add(I * S1 - S1 + S1*6*K, 100 + J * S1 + Y*S3);
       sFig_f[I].Add(I * S1 - S2 + S1*6*K, 100 + J * S1 + Y*S3);
     end;

  end;



  cube := tex_LoadFromFile('data\cube.png', $FF00FF, TEX_DEFAULT_2D);
  tex_SetFrameSize(cube, 128, 128);

  srcSiluet := TSiluet.Create('data\fg.fg');

  for I := 1 to 7 do
    Siluet[I] := TSiluet.Create(srcSiluet, I*50-50, 0, 50, 50);

  mGui := tex_LoadFromFile('data\mgui.png');

  for I := 1 to 4 do
  begin
  sGui[I] := TMeSprite.Create(mGui, 32, 32);
  for J := 0 to 3 do
    sGui[I].Add(J*32, I * 32 - 32);
  sGuiE[I] := TMeSprite.Create(mGui, 32, 32);
  for J := 0 to 3 do
    sGuiE[I].Add(128 + J*32, I * 32 - 32);
  end;

  sgui_live := TMeSprite.Create(mGui, 24, 32);
  sgui_live.add(0, 32);
  sgui_live.add(18, 32);
  sgui_live.add(128-12, 32, 12, 32);

  sgui_live_e := TMeSprite.Create(mGui, 24, 32);
  sgui_live_e.add(128 + 32 + (32-24) div 2, 0);
  sgui_live_e.add(128 +  0 + (32-24) div 2, 0);

  sgui_sh := TMeSprite.Create(mGui, 24, 32);
  sgui_sh.add(0, 0);
  sgui_sh.add(18, 0);
  sgui_sh.add(128-12, 0, 12, 32);

  sgui_sh_e := TMeSprite.Create(mGui, 24, 32);
  sgui_sh_e.add(128 + 32 + (32-24) div 2, 32);
  sgui_sh_e.add(128 +  0 + (32-24) div 2, 32);

  sgui_sword := TMeSprite.Create(mGui, 20, 32);
  sgui_sword.add(0,  128, 40, 32);
  sgui_sword.add(40, 128);
  sgui_sword.add(84, 128, 18, 32);

  sgui_sword_en := TMeSprite.Create(mGui, 20, 32);
  sgui_sword_en.add(62,  192, 44, 32);
  sgui_sword_en.add(40, 192);
  sgui_sword_en.add(0, 192);

  sgui_sword_e := TMeSprite.Create(mGui, 12, 32);
  sgui_sword_e.add(12,  160);
  sgui_sword_e.add(0, 160);

  sgui_mana := TMeSprite.Create(mGui, 20, 32);
  sgui_mana.add(128,    128);
  sgui_mana.add(128+20, 128);
  sgui_mana.add(256-28, 128, 28, 32);

  sgui_mana_e := TMeSprite.Create(mGui, 12, 32);
  sgui_mana_e.add(128 + 12, 128 + 32);
  sgui_mana_e.add(128, 128 + 32);

  sgui_exp := TMeSprite.Create(mGui, 22, 32);
  sgui_exp.add(0,  64);
  sgui_exp.add(22, 64, 22, 32);
  sgui_exp.add(64, 64, 32, 32);
  sgui_exp.add(128-12, 64, 12, 32);

  sgui_exp_e := TMeSprite.Create(mGui, 22, 32);
  sgui_exp_e.add(128 + 32 + (32-22) div 2, 64);
  sgui_exp_e.add(128 +  0 + (32-22) div 2, 64);

  sgui_heart := TMeSprite.Create(mGui, 26, 32);
  sgui_heart.add(0, 96);
  sgui_heart.add(18, 96);
  sgui_heart.add(128-24, 96);

  sgui_heart_e := TMeSprite.Create(mGui, 24, 32);
  sgui_heart_e.add(128 + 32 + (32-24) div 2, 96);
  sgui_heart_e.add(128 +  0 + (32-24) div 2, 96);

end;

end.

