program game;

uses
  Windows,
  Messages,
  OpenGL,
  iz_utils in 'izoglengine\iz_utils.pas',
  iz_types in 'izoglengine\iz_types.pas',
  iz_gfx in 'izoglengine\iz_gfx.pas',
  iz_Data in 'izoglengine\iz_Data.pas',
  iz_texture in 'izoglengine\iz_texture.pas',
  iz_sprite in 'izoglengine\iz_sprite.pas',
  iz_cfg in 'izoglengine\iz_cfg.pas',
  iz_main in 'izoglengine\iz_main.pas',
  iz_Input in 'izoglengine\iz_Input.pas',
  iz_options in 'izoglengine\iz_options.pas',
  iz_font in 'izoglengine\iz_font.pas',
  iz_inifiles in 'izoglengine\iz_inifiles.pas',
  iz_GUI in 'izoglengine\iz_GUI.pas',
  GPAHeader in 'headers\GPAHeader.pas',
  g_Data in 'GameEn\g_Data.pas',
  g_Types in 'GameEn\g_Types.pas',
  g_Main in 'GameEn\g_Main.pas',
  g_World in 'GameEn\g_World.pas',
  g_GUI in 'GameEn\g_GUI.pas',
  g_Land_load in 'GameEn\g_Land_load.pas',
  g_Land in 'GameEn\g_Land.pas',
  g_Camera in 'GameEn\g_Camera.pas',
  g_Character_Load in 'GameEn\g_Character_Load.pas',
  g_Character in 'GameEn\g_Character.pas',
  g_Monster_Load in 'GameEn\g_Monster_Load.pas',
  g_Monster in 'GameEn\g_Monster.pas',
  g_Utils in 'GameEn\g_Utils.pas',
  g_Base in 'GameEn\g_Base.pas',
  g_Tower in 'GameEn\g_Tower.pas',
  g_miniMap in 'GameEn\g_miniMap.pas',
  g_Game in 'GameEn\g_Game.pas';

//Линкуем ресурсные файлы
{$R sys\ico.res}

begin
  if FindWindow(AppName,AppName) <> 0 then Exit;
  Gfx := izGfx.Create(@WinProc);
  Gfx.Init;
  VSync(Options.vSync);
  MainInit();

  while not Gfx.Quit do begin
    if PeekMessage(gfx.Msg, gfx.WinHWND, 0, 0, PM_REMOVE) then //Обработка сообщений
    begin
      TranslateMessage(gfx.msg);
      DispatchMessage(gfx.msg);
    end;
    if gfx.FActive then
    begin
      MainUpdate();
      MainDraw();
      gfx.FPSUpdate();
    end
     else
     if ((not gfx.Fokus) and (not gfx.Minimize)) then
      begin
        gfx.FPSUpdate();
        if gfx.DeltaTime >= 1000 then MainDraw() else Sleep(1);
      end
     else
     Sleep(1);
   end;
    MainDestroy();
    gfx.DestroyGfx();
end.




