unit Main;

interface

uses
  JEN_Header,
  JEN_MAth,
  game;

type
  TShooter = class(TInterfacedObject, IGame)
  constructor Create;
  public
    procedure LoadContent; stdcall;
    procedure OnUpdate(dt: LongInt); stdcall;
    procedure OnRender; stdcall;
    procedure Close; stdcall;
  end;

var
  Engine : IJenEngine;
  Display : IDisplay;
  Render : IRender;
  Render2d : IRender2d;
  Utils : IUtils;
  Input : IInput;
  Shooter : IGame;
  Helpers : IHelpers;
  Log : ILog;
  ResMan : IResourceManager;
  Game : TGame;

implementation

uses
  Config;

constructor TShooter.Create;
begin
  GetJenEngine(Engine);

  Engine.GetSubSystem(ssDisplay, IJenSubSystem(Display));
  Engine.GetSubSystem(ssUtils, IJenSubSystem(Utils));
  Engine.GetSubSystem(ssInput, IJenSubSystem(Input));
  Engine.GetSubSystem(ssLog, IJenSubSystem(Log));
  Engine.GetSubSystem(ssHelpers, IJenSubSystem(Helpers));
  Engine.GetSubSystem(ssRender, IJenSubSystem(Render));
  Engine.GetSubSystem(ssRender2d, IJenSubSystem(Render2d));
  Engine.GetSubSystem(ssResMan, IJenSubSystem(ResMan));
  Display.Init(Screen_Width, Screen_Height, 0, false);
  Render.Init();
  Display.SetVSync(false);
  Engine.Start(self);
end;

procedure TShooter.LoadContent;
begin
  Game := TGame.Create;
  Game.Init;
end;

procedure TShooter.OnUpdate(dt: LongInt);
begin
  Display.Caption := Utils.IntToStr(Display.FPS);
  Game.OnUpdate(dt);
end;

procedure TShooter.OnRender;
begin
  Game.OnRender;
end;

procedure TShooter.Close;
begin
  Game.Free;

  Display  := nil;
  Utils    := nil;
  Render   := nil;
  Render2d := nil;
  ResMan   := nil;
  Engine   := nil;
  Helpers  := nil;
  Input    := nil;
end;



end.
