unit quod_C;

interface
uses
  Map, MForm, Model, quod_A, Windows, Messages,
  Forms, SysUtils, Keyboard, Lives ;

procedure loadlevel(FN : string);
procedure presskey;

var
  SCRIPTF : string;
  NHero : byte;
  WMenu, WGame: boolean;
  dt : double;

implementation

procedure loadlevel(FN : string);
var
  F : textfile;
  S : string;
begin
  FN:='\Map\1.txt';
  FN:=ExtractFilePath(Application.ExeName)+FN;
  if FileExists(FN) then
    begin
      assign(F, FN);
      reset(F);
      readln(F, NHero);
      readln(F, S);
      closefile(F);
    end;
   Map.Load(S);
   quod_A.QCamera.TargetObject:=Model.Pers[NHero].A;
   Model.Pers[NHero].Au.Visible:=false;
   WMenu:=false;
   WGame:=true;
end;

// Обработка нажатия клавиш
procedure presskey;
var
  X,Y, MX,MY :real;
begin
  MX:=0;
  MY:=0;
  if IsKeyDown(VK_Down) or IsKeyDown('s') or IsKeyDown('ы') then
  MY:=MY-C*dT;
  if IsKeyDown(VK_Up) or IsKeyDown('w') or IsKeyDown('ц') then
  MY:=MY+C*dT;
  if IsKeyDown(VK_Left) or IsKeyDown('a') or IsKeyDown('ф') then
  MX:=MX-C*dT;
  if IsKeyDown(VK_Right) or IsKeyDown('d') or IsKeyDown('в') then
  MX:=MX+C*dT;

  with Model.Pers[Nhero] do
    begin
      X:=A.Position.X;
      Y:=A.Position.Y;
      MoveObj(MX,MY,Model.EtLiveObj[Et].R, X,Y,Nhero, X,Y );
      A.Position.X:=X;
      A.Position.Y:=Y;
      if (MX<>0) or (MY<>0)
      then
        begin
          if A.Animation<>'2' then
          A.Animation:='2';
        end;  
    end;
//  roll(Nhero);
  GameCube.Position:=Model.Pers[Nhero].A.Position;
end;

end.
