uses crt,gfx3,tmap2,tcamlib2;

Var Ch:Char;


Procedure RotatedCamera;
Begin
TXoff:=80;
TYOff:=100;
Tzoff:=-2430;
Path:=0;
Zobs2:=700;
 repeat
   If Left Then
    trotatepoints2(90,0,(360-Whe)+FG)
     Else
      trotatepoints2(90,0,Whe+Fg);
   Dir:=Dir mod 360;
   If Path<43 Then Tzoff:=Tzoff+50 Else TZoff:=TZoff-50;
   If TYoff<120 Then TYOff:=TYoff+1;
   If (Path>32) And (Path<51)  Then
    Begin
     Dir:=Dir-20;
     Fg:=Fg+10;
    End;
   inc(path);
   MakeVoxel(x,y,dir);
   TShowText(Vaddr);
   If (Path Mod 10 in[1..4]) Then PutRec;
   PutAlways;
   WaitRetrace;
   Flip32(Vaddr,Sega000);
 until Keypressed;
End;


Procedure RocketCamera;
Var Tc:Word;
Begin
TXoff:=160;
Tzoff:=-400;
TYOff:=120;
X:=100;
Y:=50;
Tc:=0;
 repeat
    Inc(Tc);
    TXoff:=Round(Cos(TC/10)*70)+160;                {Move Armonically}
    TYoff:=Round(Sin(TC/5)*10)+120;               {............... }
    Whe:=Abs(360+Round(Cos((TC+120)/16)*7)) mod 360;{...........     }
    deg2:=Sin(TC/10)*15;                           {............... }
    deg:=1+Sin(TC/10)*2;                           {............... }
    zobs2:=600+Round(Sin(TC/10)*45);               {............... }
    Tzoff:=-250-Tc*10;{Round(Sin(TC/10)*145);      {............... }
    if keypressed then ch:=readkey;
    If Left Then
     trotatepoints2(278,180,(360-Whe))
      Else
       trotatepoints2(278,180,Whe);
    Dir:=Dir mod 360;

    inc(path);
    MakeVoxel(x,y,dir);
    TShowText(Vaddr);
    If (Path Mod 10 in[1..4]) Then PutRec;
    PutAlways;
    WaitRetrace;
    Flip32(Vaddr,Sega000);
    if ch='3' then begin deg:=deg+0.2;  end;
    if ch='9' then begin deg:=deg-0.2;  end;
    if ch='4' then
     Begin
      If (Left=False) And (Whe>0) Then
       Begin
        Dec(Whe,4);
        Dec(Dir,4);
       End
       Else
        Begin
         Left:=True;
         dec(dir,4);
         If Whe<30 Then Inc(Whe,4);
        End;
     End
      Else
       If (Whe>0) and (Left) Then Dec(Whe,4);

    if ch='6' then
     Begin
      If (Left) And (Whe>0) Then
       Begin
        Dec(Whe,4);
        Inc(Dir,4);
       End
       Else
        Begin
         Left:=False;
         Inc(dir,4);
          If Whe<30 Then Inc(Whe,4);
        End;
       End Else
         If (Whe>0) and (Left=False) Then Dec(Whe,4);

{    if (ch='m') And (Deg2>-2) then deg2:=deg2-0.5;
    if (ch='n') And (Deg2<2) then deg2:=deg2+0.5;}
{    if ch='-' then zobs2:=zobs2-13;
    if ch='+' then zobs2:=zobs2+13;}
{    if ch='8' then}
      begin
        y:=y+round(3*cos(dir/180*pi));
        x:=x+round(3*sin(dir/180*pi));
      end;
    if ch='2' then
      begin
        y:=y-round(6*cos(dir/180*pi));
        x:=x-round(6*sin(dir/180*pi));
      end;
until ch=' ';
End;




Procedure RocketCamera2;
Var Tc:Word;
Begin
TXoff:=160;
Tzoff:=-400;
TYOff:=120;
X:=100;
Y:=50;
Tc:=0;
 repeat
    Inc(Tc);
    TXoff:=Round(Cos(TC/10)*70)+160;                {Move Armonically}
    TYoff:=Round(Sin(TC/5)*10)+120;               {............... }
    Whe:=Abs(360+Round(Cos((TC+120)/16)*7)) mod 360;{...........     }
    deg2:=Sin(TC/10)*15;                           {............... }
    deg:=1+Sin(TC/10)*2;                           {............... }
    zobs2:=600+Round(Sin(TC/10)*45);               {............... }
    if keypressed then ch:=readkey;
    If Left Then
     trotatepoints2(278,180,(360-Whe))
      Else
       trotatepoints2(278,180,Whe);
    Dir:=Dir mod 360;

    inc(path);
    MakeVoxel(x,y,dir);
    TShowText(Vaddr);
    If (Path Mod 10 in[1..4]) Then PutRec;
    PutAlways;
    WaitRetrace;
    Flip32(Vaddr,Sega000);
    if ch='3' then begin deg:=deg+0.2;  end;
    if ch='9' then begin deg:=deg-0.2;  end;
    if ch='4' then
     Begin
      If (Left=False) And (Whe>0) Then
       Begin
        Dec(Whe,4);
        Dec(Dir,4);
       End
       Else
        Begin
         Left:=True;
         dec(dir,4);
         If Whe<30 Then Inc(Whe,4);
        End;
     End
      Else
       If (Whe>0) and (Left) Then Dec(Whe,4);

    if ch='6' then
     Begin
      If (Left) And (Whe>0) Then
       Begin
        Dec(Whe,4);
        Inc(Dir,4);
       End
       Else
        Begin
         Left:=False;
         Inc(dir,4);
          If Whe<30 Then Inc(Whe,4);
        End;
       End Else
         If (Whe>0) and (Left=False) Then Dec(Whe,4);

{    if (ch='m') And (Deg2>-2) then deg2:=deg2-0.5;
    if (ch='n') And (Deg2<2) then deg2:=deg2+0.5;}
{    if ch='-' then zobs2:=zobs2-13;
    if ch='+' then zobs2:=zobs2+13;}
{    if ch='8' then}
      begin
        y:=y+round(3*cos(dir/180*pi));
        x:=x+round(3*sin(dir/180*pi));
      end;
    if ch='2' then
      begin
        y:=y-round(6*cos(dir/180*pi));
        x:=x-round(6*sin(dir/180*pi));
      end;
until ch=' ';
End;




begin
 SetMCGA;
 setupvirtual;
 SetUpCamerasForVoxel;
 Pal(255,0,0,0);
 Repeat
  RotatedCamera;
  If Readkey=#27 Then
   Begin
    ShutDown;
    ShutDownCamerasForVoxel;
    SetText;
    Halt;
   End;
  RocketCamera2;
 Until 1=2;
 shutdown;
 SetText;
end.