unit Picture1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, MPlayer, ExtCtrls, jpeg, TransparentPanel, GIFImage,
  Spin, pngimage;

type
  TPic1 = class(TForm)
    Video1: TMediaPlayer;
    Image1: TImage;
    Music1: TMediaPlayer;
    left_sensor: TImage;
    right_sensor: TImage;
    bottom_sensor: TImage;
    TopSensor: TImage;
    CenterSensor: TImage;
    Inventar0: TMediaPlayer;
    InvBev: TBevel;
    InvPic: TImage;
    inv_delay: TTimer;
    procedure Video1Notify(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Music1Notify(Sender: TObject);
    procedure right_sensorDblClick(Sender: TObject);
    procedure left_sensorDblClick(Sender: TObject);
    procedure bottom_sensorDblClick(Sender: TObject);
    procedure TopSensorDblClick(Sender: TObject);
    procedure CenterSensorDblClick(Sender: TObject);
    procedure Inventar0Notify(Sender: TObject);
    procedure InventarClick(Sender: TObject);
    procedure InvPicMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure CenterSensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure InvPicEndDrag(Sender, Target: TObject; X, Y: Integer);
    procedure CenterSensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure InvPicClick(Sender: TObject);
    procedure InvPicDblClick(Sender: TObject);
    procedure inv_delayTimer(Sender: TObject);
  private
    { Private declarations }
    procedure Book_aClick(Sender: TObject);
    procedure fwpageClick(Sender: TObject);
    procedure bwpageClick(Sender: TObject);
    procedure Videoplay(videofile:string);
    procedure pagecreate;
    procedure pagesound;
    procedure Bookplay(videofile:string);
    procedure Bookdisplay(imagename:string);
  public
    Starused,Finished,swordused, finished2, final3access, inventarclose:Boolean;
    Status:Integer;
    bwpage, fwpage:TImage;
    book_a: TImage;
    { Public declarations }
  end;

var
  Pic1: TPic1;

var
  Panel:TTransparentPanel;
  InvPanel0:TTransparentPanel;

implementation

uses evo_menu, Picture2, help_evo, Picture3, Picture4;



{$R *.dfm}

procedure TPic1.Videoplay(videofile:string);
begin
 Panel:=TTransparentPanel.Create(self);
 Panel.Parent := Self;
 Panel.Left := 72;
 Panel.Top := 40;
 Panel.Width:=640;
 Panel.Height:=480;

 video1.FileName:=videofile;

 video1.Open;
 video1.Display:=panel;
 video1.DisplayRect:=Panel.ClientRect;
 video1.play;
end;

procedure TPic1.PageCreate;
begin
 bwpage:=TImage.Create(self);
 bwpage.Parent := Self;
 bwpage.Left := 72;
 bwpage.Top := 40;
 bwpage.Width:=320;
 bwpage.Height:=480;
 bwpage.OnClick:=bwpageClick;

 fwpage:=TImage.Create(self);
 fwpage.Parent := Self;
 fwpage.Left :=392;
 fwpage.Top := 40;
 fwpage.Width:=320;
 fwpage.Height:=480;
 fwpage.OnClick:=fwpageClick;
end;

procedure TPic1.Bookplay(videofile:string);
begin
 InvPanel0:=TTransparentPanel.Create(self);
 InvPanel0.Parent := Self;
 InvPanel0.Left := 72;
 InvPanel0.Top := 40;
 InvPanel0.Width:=640;
 InvPanel0.Height:=480;

 inventar0.FileName:=videofile;
 inventar0.Open;
 inventar0.Display:=invpanel0;
 inventar0.DisplayRect:=invPanel0.ClientRect;
 inventar0.play;
end;

procedure TPic1.BookDisplay(imagename:string);
begin
 Book_a:=TImage.Create(self);
 Book_a.Parent := Self;
 Book_a.Left := 72;
 Book_a.Top := 40;
 Book_a.Width:=640;
 Book_a.Height:=480;
 Book_a.OnClick:=Book_aClick;
 Book_a.Picture.loadfromfile(imagename);
end;

procedure TPic1.PageSound;
begin
 inventar0.FileName:='resources\books\page.wav';
 inventar0.Open;
 inventar0.play;
 inventarclose:=true;
end;

procedure TPic1.Video1Notify(Sender: TObject);
begin
 with Sender as TMediaPlayer do
   begin
     case Mode of
       mpStopped:
        begin
         panel.free;
         if status=0 then
          begin
           if final3access=false then
            begin
             image1.Picture.LoadFromFile('resources\img\1_001.jpeg');
            end
           else
            begin
             image1.Picture.LoadFromFile('resources\img\2_127.jpeg');
            end
           end;

         if status=1 then image1.Picture.LoadFromFile('resources\img\1_002.jpeg');
         if status=2 then image1.Picture.LoadFromFile('resources\img\1_003.jpeg');
         if status=3 then image1.Picture.LoadFromFile('resources\img\1_004.jpeg');
         if status=4 then image1.Picture.LoadFromFile('resources\img\1_005.jpeg');

         if finished=true then
          begin
           music1.Notify:=false;
           music1.Stop;
           pic1.hide;
           pic2.show;

           finished:=false;
          end;

         if finished2=true then
          begin
           music1.Notify:=false;
           music1.Stop;
           pic1.hide;
           pic3.show;

           finished2:=false;
          end;

         if status=5 then
          begin
           pic2.video2:=false;
           Music1.FileName:='resources\music\a.avi';
           Music1.Open;
           Music1.play;
           Music1.notify:=true;
           invpic.visible:=true;
           status:=0;
           image1.Picture.LoadFromFile('resources\img\1_001.jpeg');
          end;

         if status=6 then
          begin
           pic3.final2:=false;
           Music1.FileName:='resources\music\a.avi';
           Music1.Open;
           Music1.play;
           Music1.notify:=true;
           invpic.visible:=true;
           inv_delay.enabled:=true;
           final3access:=true;
           image1.Picture.LoadFromFile('resources\img\2_127.jpeg');
           status:=0;
          end;

         if status=7 then
          begin
           music1.Notify:=false;
           music1.pause;

           pic1.Hide;
           pic4.show;
          end;

        end
     end;
     Notify := True;
   end;
end;

procedure TPic1.FormActivate(Sender: TObject);
begin
 if pic2.video2=true then image1.Picture.LoadFromFile('resources\img\black.jpeg')
else
 if pic3.final2=true then image1.Picture.LoadFromFile('resources\img\black.jpeg')
else
  begin
   if status=0 then image1.Picture.LoadFromFile('resources\img\1_001.jpeg');
   if status=1 then image1.Picture.LoadFromFile('resources\img\1_002.jpeg');
   if status=2 then image1.Picture.LoadFromFile('resources\img\1_003.jpeg');

   Music1.FileName:='resources\music\a.avi';
   Music1.Open;
   Music1.play;
   Music1.notify:=true;

   Status:=0;

   if pic3.exit2node=true then status:=2;

   if Starused=false then
    begin
     invpic.Picture.loadfromfile('resources\inv\star.gif');
     pic2.displayeditem:='star';
     end;
  end;
end;

procedure TPic1.Music1Notify(Sender: TObject);
begin
 if music1.NotifyValue=nvSuccessful then
  begin
    music1.Play;
    music1.Notify := True;
  end
end;

procedure TPic1.right_sensorDblClick(Sender: TObject);
begin
 if (status=0) and (final3access=false) then
  begin
   videoplay('resources\anim\1_003.avi');
   status:=2;
  end
else
 if (status=0) and (final3access=true) then
  begin
   videoplay('resources\anim\2_374.avi');
   status:=2;
  end
else
 if status=2 then
  begin
   videoplay('resources\anim\1_009.avi');
   status:=1;
  end
else
 if (status=1) and (final3access=false)then
  begin
   videoplay('resources\anim\1_004.avi');
   status:=0;
  end
else
  if (status=1) and (final3access=true)then
  begin
   videoplay('resources\anim\2_377.avi');
   status:=0;
  end
else
 if (status=3) and (final3access=false) then
  begin
   videoplay('resources\anim\1_013.avi');
   status:=0;
  end
else
 if (status=3) and (final3access=true) then
  begin
   videoplay('resources\anim\2_379.avi');
   status:=0;
  end
else
 if status=4 then
  begin
   videoplay('resources\anim\1_017.avi');
   status:=3;
  end;
end;

procedure TPic1.left_sensorDblClick(Sender: TObject);
begin
 if (status=0) and (final3access=false) then
  begin
   videoplay('resources\anim\1_002.avi');
   status:=1;
  end
else
 if (status=0) and (final3access=true) then
  begin
   videoplay('resources\anim\2_373.avi');
   status:=1;
  end
else
 if status=1 then
  begin
   videoplay('resources\anim\1_005.avi');
   status:=2;
  end
else
 if (status=2) and (final3access=false) then
  begin
   videoplay('resources\anim\1_006.avi');
   status:=0;
  end
else
 if (status=2) and (final3access=true) then
  begin
   videoplay('resources\anim\2_378.avi');
   status:=0;
  end
else
 if status=3 then
  begin
   videoplay('resources\anim\1_015.avi');
   status:=2;
  end
else
 if status=4 then
  begin
   videoplay('resources\anim\1_017.avi');
   status:=3;
  end;
end;

procedure TPic1.bottom_sensorDblClick(Sender: TObject);
begin
if (status=0) and (final3access=false) then
  begin
   videoplay('resources\anim\1_010.avi');
   status:=3;
  end
else
if (status=0) and (final3access=true) then
  begin
   videoplay('resources\anim\2_375.avi');
   status:=3;
  end
else
 if status=1 then
  begin
   videoplay('resources\anim\1_011.avi');
   status:=3;
  end
else
 if status=2 then
  begin
   videoplay('resources\anim\1_012.avi');
   status:=3;
  end
else
 if status=4 then
  begin
   videoplay('resources\anim\1_017.avi');
   status:=3;
  end;
end;

procedure TPic1.TopSensorDblClick(Sender: TObject);
begin
 if status=3 then
  begin
   videoplay('resources\anim\1_014.avi');
   status:=1;
  end
else
 if status=4 then
  begin
   videoplay('resources\anim\1_017.avi');
   status:=3;
  end;
end;

procedure TPic1.CenterSensorDblClick(Sender: TObject);
begin
if (status=0) and (final3access=true) then
  begin
   videoplay('resources\anim\2_376.avi');
   status:=7;
  end
else
if (status=0) and (pic2.templeexitnode=false) then
  begin
   videoplay('resources\anim\1_001.avi');
  end
 else
if (status=0) and (pic2.templeexitnode=true) then
  begin
   videoplay('resources\anim\1_021.avi');
  end
else
 if status=1 then
  begin
   if starused=true then
    begin
     videoplay('resources\anim\1_019.avi');
     finished:=true;
    end
 else
  begin
   videoplay('resources\anim\1_007.avi');
  end
 end
else
 if (status=2) and (swordused=false) then
  begin
   videoplay('resources\anim\1_008.avi');
  end
 else
if (status=2) and (swordused=true) then
  begin
   videoplay('resources\anim\1_022.avi');
   finished2:=true;
  end
 else
 if status=3 then
  begin
   videoplay('resources\anim\1_016.avi');
   status:=4;
  end
else
 if status=4 then
  begin
   videoplay('resources\anim\1_017.avi');
   status:=3;
  end;
end;

procedure TPic1.Inventar0Notify(Sender: TObject);
begin
 with Sender as TMediaPlayer do
   begin
     case Mode of
      mpStopped:
        begin
         if pic3.book3open=true then
          begin
           invpanel0.free;
           book_a.Picture.LoadFromFile('resources\books\2_063_b.jpeg');
           invpic.Enabled:=true;
           inventar0.Close;
          end
        else
         if pic2.pages=0 then
          begin
           Invpanel0.free;
           pic2.pages:=1;
           book_a.Picture.LoadFromFile('resources\books\2_029.jpeg');
           invpic.enabled:=true;
           pagecreate;
           inventar0.Close;
          end
        else
         if pic2.pages=6 then
          begin
           Invpanel0.free;
           pic2.pages:=7;
           book_a.Picture.LoadFromFile('resources\books\2_052.jpeg');
           invpic.enabled:=true;
           pagecreate;
           inventar0.Close;
          end;
         if inventarclose=true then
          begin
           inventar0.Close;
           inventarclose:=false;
          end;
        end;
      end;
   end;
end;

procedure TPic1.InventarClick(Sender: TObject);
begin
 close;
end;

procedure TPic1.InvPicMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 if (Button = mbRight) and (Pic2.displayeditem='star') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (Pic2.displayeditem='sword') then InvPic.BeginDrag(False);
end;

procedure TPic1.CenterSensorDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
 if (source = InvPic) and (pic2.displayeditem='star') then
  begin
   videoplay('resources\anim\1_018.avi');
  end
else
 if (source = InvPic) and (pic2.displayeditem='sword') then
  begin
   videoplay('resources\anim\1_020.avi');
  end
end;

procedure TPic1.InvPicEndDrag(Sender, Target: TObject; X, Y: Integer);
begin
 if (Target = CenterSensor) then
  begin
   if pic2.displayeditem='star' then
    begin
     Invpic.picture.loadfromfile('resources\img\black.jpeg');
     Starused:=true;
     //pic2.invitem:=1;
    end
  else
   if pic2.displayeditem='sword' then
    begin
     Invpic.picture.loadfromfile('resources\img\black.jpeg');
     Swordused:=true;
     pic2.sword:=false;
     inv_delay.enabled:=true;
    end
  end
end;

procedure TPic1.CenterSensorDragOver(Sender, Source: TObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
begin
 if Status=4 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 music1.notify:=false;
 music1.stop;
 evomenu.show;
end;

procedure TPic1.FormShow(Sender: TObject);
begin
 if (pic2.video2=true) and (pic3.final2=false) then
  begin
   invpic.Visible:=false;

   videoplay('resources\video\island_flyby.avi');

   status:=5;
   starused:=true;
  end
 else
  if pic3.final2=true then
  begin
   invpic.Visible:=false;

   videoplay('resources\video\flyby2.avi');

   status:=6;
   //starused:=true;
  end;

 if Pic2.displayeditem='book' then
  begin
   InvPic.Picture.loadfromfile('resources\inv\book.gif');
   pic2.displayeditem:='book';
  end
  else
 if Pic2.displayeditem='shirt' then InvPic.Picture.loadfromfile('resources\inv\shirt.gif')
  else
 if Pic2.displayeditem='coins' then InvPic.Picture.loadfromfile('resources\inv\coins.gif')
  else
 if Pic2.displayeditem='spear' then InvPic.Picture.loadfromfile('resources\inv\spear.gif')
  else
 if Pic2.displayeditem='medallion' then InvPic.Picture.loadfromfile('resources\inv\medallion.gif')
  else
 if Pic2.displayeditem='book2' then
  begin
   InvPic.Picture.loadfromfile('resources\inv\book2.gif');
   pic2.displayeditem:='book2';
  end
  else
 if Pic2.displayeditem='token' then InvPic.Picture.loadfromfile('resources\inv\token.gif')
  else
 if Pic2.displayeditem='lens' then InvPic.Picture.loadfromfile('resources\inv\lens.gif')
  else
 if Pic2.displayeditem='blanket' then InvPic.Picture.loadfromfile('resources\inv\blanket.gif')
  else
 if Pic2.displayeditem='scroll' then InvPic.Picture.loadfromfile('resources\inv\scroll.gif')
  else
 if Pic2.displayeditem='spear2' then InvPic.Picture.loadfromfile('resources\inv\spear2.gif')
  else
 if Pic2.displayeditem='spear3' then InvPic.Picture.loadfromfile('resources\inv\spear3.gif')
  else
 if Pic2.displayeditem='flask1' then InvPic.Picture.loadfromfile('resources\inv\flask1.gif')
  else
 if Pic2.displayeditem='key1' then InvPic.Picture.loadfromfile('resources\inv\key1.gif')
  else
 if Pic2.displayeditem='flask_empty' then InvPic.Picture.loadfromfile('resources\inv\flask_empty.gif')
  else
 if Pic2.displayeditem='sword' then
  begin
   InvPic.Picture.loadfromfile('resources\inv\sword.gif');
   pic2.displayeditem:='sword';
  end
  else
 if Pic2.displayeditem='crowbar' then InvPic.Picture.loadfromfile('resources\inv\crowbar.gif')
  else
 if Pic2.displayeditem='dust' then InvPic.Picture.loadfromfile('resources\inv\dust.gif')
  else
 if Pic2.displayeditem='card' then InvPic.Picture.loadfromfile('resources\inv\card.gif')
  else
 if Pic2.displayeditem='stone' then InvPic.Picture.loadfromfile('resources\inv\stone.gif')
  else
 if Pic2.displayeditem='mirror' then InvPic.Picture.loadfromfile('resources\inv\mirror.gif')
  else
 if Pic2.displayeditem='shieldbook' then InvPic.Picture.loadfromfile('resources\inv\shieldbook.gif')
  else
 if Pic2.displayeditem='cloak' then InvPic.Picture.loadfromfile('resources\inv\cloak.gif')
  else
 if Pic2.displayeditem='powder' then InvPic.Picture.loadfromfile('resources\inv\powder.gif')
  else
 if Pic2.displayeditem='yellowflask' then InvPic.Picture.loadfromfile('resources\inv\flask_yellow.gif')
  else
 if Pic2.displayeditem='paper' then InvPic.Picture.loadfromfile('resources\inv\paper.gif')
  else
 if Pic2.displayeditem='waterflask' then InvPic.Picture.loadfromfile('resources\inv\flask2.gif')
  else
 if Pic2.displayeditem='glass1' then InvPic.Picture.loadfromfile('resources\inv\glass1.gif')
  else
 if Pic2.displayeditem='glass2' then InvPic.Picture.loadfromfile('resources\inv\glass2.gif')
  else
 if Pic2.displayeditem='glass3' then InvPic.Picture.loadfromfile('resources\inv\glass3.gif')
 else
 if Pic2.displayeditem='shieldbook2' then
  begin
   InvPic.Picture.loadfromfile('resources\inv\shieldbook2.gif');
   pic2.displayeditem:='shieldbook2';
  end;
end;

procedure TPic1.InvPicClick(Sender: TObject);
begin
 Inv_delay.Enabled:=true;
end;

procedure TPic1.InvPicDblClick(Sender: TObject);
begin
 inv_delay.enabled:=false;
 if (pic2.book1open=false) and (pic2.book2open=false) and (pic2.displayeditem='book') then
  begin
   Bookdisplay('resources\books\2_028.jpeg');
   pic2.pages:=0;
   pic2.book1open:=true;
  end
else
  if (pic2.book1open=true) and (pic2.displayeditem='book') then
   begin
    if pic2.pages>=1 then fwpage.Free;
    if pic2.pages>=1 then bwpage.Free;
    book_a.free;
    pic2.book1open:=false;
   end
else
 if (pic2.book2open=false) and (pic2.book1open=false) and (pic2.displayeditem='book2') then
  begin
   Bookdisplay('resources\books\2_051.jpeg');
   pic2.pages:=6;
   pic2.book2open:=true;
  end
else
  if (pic2.book2open=true) and (pic2.displayeditem='book2') then
   begin
    if pic2.pages>=7 then fwpage.Free;
    if pic2.pages>=7 then bwpage.Free;
    book_a.free;
    pic2.book2open:=false;
   end
else
 if (pic3.book3open=false) and (pic2.book2open=false) and (pic2.book1open=false) and (pic2.displayeditem='shieldbook') then
  begin
   Bookdisplay('resources\books\2_063_a.jpeg');
   pic3.book3open:=true;
  end
else
if (pic3.book3open=true) and (pic2.displayeditem='shieldbook') then
 begin
  book_a.free;
  pic3.book3open:=false;
  pic3.book3opened:=false;
 end;
end;

procedure TPic1.inv_delayTimer(Sender: TObject);
begin
 pic2.finite:=false;

 pic2.cycles:=0;

 repeat
 if pic2.invitem<31 then pic2.invitem:=pic2.invitem+1 else
  begin
   pic2.invitem:=1;
   pic2.cycles:=1;
  end;

 if (pic2.invitem=1) and (pic2.book=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=1) and (pic2.book=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\book.gif');
   pic2.displayeditem:='book';
   pic2.finite:=true;
  end;

 if (pic2.invitem=2) and (pic2.drawerempty=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=2) and (pic2.drawerempty=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shirt.gif');
   pic2.displayeditem:='shirt';
   pic2.finite:=true;
  end;

 if (pic2.invitem=3) and (pic2.coins=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=3) and (pic2.coins=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\coins.gif');
   pic2.displayeditem:='coins';
   pic2.finite:=true;
  end;

 if (pic2.invitem=4) and (pic2.spear=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=4) and (pic2.spear=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear.gif');
   pic2.displayeditem:='spear';
   pic2.finite:=true;
  end;

 if (pic2.invitem=5) and (pic2.medallion=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=5) and (pic2.medallion=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\medallion.gif');
   pic2.displayeditem:='medallion';
   pic2.finite:=true;
  end;

 if (pic2.invitem=6) and (pic2.book2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=6) and (pic2.book2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\book2.gif');
   pic2.displayeditem:='book2';
   pic2.finite:=true;
  end;

 if (pic2.invitem=7) and (pic2.token=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=7) and (pic2.token=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\token.gif');
   pic2.displayeditem:='token';
   pic2.finite:=true;
  end;

 if (pic2.invitem=8) and (pic2.lens=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=8) and (pic2.lens=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\lens.gif');
   pic2.displayeditem:='lens';
   pic2.finite:=true;
  end;

 if (pic2.invitem=9) and (pic2.blanket=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=9) and (pic2.blanket=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\blanket.gif');
   pic2.displayeditem:='blanket';
   pic2.finite:=true;
  end;

 if (pic2.invitem=10) and (pic2.scroll=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=10) and (pic2.scroll=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\scroll.gif');
   pic2.displayeditem:='scroll';
   pic2.finite:=true;
  end;

 if (pic2.invitem=11) and (pic2.spear2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=11) and (pic2.spear2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear2.gif');
   pic2.displayeditem:='spear2';
   pic2.finite:=true;
  end;

 if (pic2.invitem=12) and (pic2.spear3=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=12) and (pic2.spear3=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear3.gif');
   pic2.displayeditem:='spear3';
   pic2.finite:=true;
  end;

 if (pic2.invitem=13) and (pic2.flask1=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=13) and (pic2.flask1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask1.gif');
   pic2.displayeditem:='flask1';
   pic2.finite:=true;
  end;

 if (pic2.invitem=14) and (pic2.key1=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=14) and (pic2.key1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\key1.gif');
   pic2.displayeditem:='key1';
   pic2.finite:=true;
  end;

 if (pic2.invitem=15) and (pic2.emptyflask=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=15) and (pic2.emptyflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask_empty.gif');
   pic2.displayeditem:='emptyflask';
   pic2.finite:=true;
  end;

 if (pic2.invitem=16) and (pic2.sword=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=16) and (pic2.sword=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\sword.gif');
   pic2.displayeditem:='sword';
   pic2.finite:=true;
  end;

 if (pic2.invitem=17) and (pic3.crowbar=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=17) and (pic3.crowbar=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\crowbar.gif');
   pic2.displayeditem:='crowbar';
   pic2.finite:=true;
  end;

 if (pic2.invitem=18) and (pic3.dust=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=18) and (pic3.dust=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\dust.gif');
   pic2.displayeditem:='dust';
   pic2.finite:=true;
  end;

 if (pic2.invitem=19) and (pic3.card=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=19) and (pic3.card=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\card.gif');
   pic2.displayeditem:='card';
   pic2.finite:=true;
  end;

 if (pic2.invitem=20) and (pic3.stone=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=20) and (pic3.stone=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\stone.gif');
   pic2.displayeditem:='stone';
   pic2.finite:=true;
  end;

 if (pic2.invitem=21) and (pic3.mirror=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=21) and (pic3.mirror=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\mirror.gif');
   pic2.displayeditem:='mirror';
   pic2.finite:=true;
  end;

 if (pic2.invitem=22) and (pic3.shieldbook=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=22) and (pic3.shieldbook=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shieldbook.gif');
   pic2.displayeditem:='shieldbook';
   pic2.finite:=true;
  end;

 if (pic2.invitem=23) and (pic3.cloak=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=23) and (pic3.cloak=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\cloak.gif');
   pic2.displayeditem:='cloak';
   pic2.finite:=true;
  end;

 if (pic2.invitem=24) and (pic3.powder=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=24) and (pic3.powder=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\powder.gif');
   pic2.displayeditem:='powder';
   pic2.finite:=true;
  end;

 if (pic2.invitem=25) and (pic3.yellowflask=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=25) and (pic3.yellowflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask_yellow.gif');
   pic2.displayeditem:='yellowflask';
   pic2.finite:=true;
  end;

 if (pic2.invitem=26) and (pic3.paper=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=26) and (pic3.paper=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\paper.gif');
   pic2.displayeditem:='paper';
   pic2.finite:=true;
  end;

 if (pic2.invitem=27) and (pic3.waterflask=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=27) and (pic3.waterflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask2.gif');
   pic2.displayeditem:='waterflask';
   pic2.finite:=true;
  end;

 if (pic2.invitem=28) and (pic3.glass1=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=28) and (pic3.glass1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass1.gif');
   pic2.displayeditem:='glass1';
   pic2.finite:=true;
  end;

 if (pic2.invitem=29) and (pic3.glass2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=29) and (pic3.glass2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass2.gif');
   pic2.displayeditem:='glass2';
   pic2.finite:=true;
  end;

 if (pic2.invitem=30) and (pic3.glass3=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=30) and (pic3.glass3=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass3.gif');
   pic2.displayeditem:='glass3';
   pic2.finite:=true;
  end;

 if (pic2.invitem=31) and (pic3.shieldbook2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=31) and (pic3.shieldbook2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shieldbook2.gif');
   pic2.displayeditem:='shieldbook2';
   pic2.finite:=true;
  end;

until (pic2.cycles=1) or (pic2.finite=true);

inv_delay.enabled:=false;

end;

procedure Tpic1.Book_aClick(Sender: TObject);
begin
 if (pic3.book3opened=false) and (pic2.book2open=false) and (pic2.book1open=false) then
  begin
   invPanel0:=TTransparentPanel.Create(self);
   invPanel0.Parent := Self;
   invPanel0.Left := 72;
   invPanel0.Top := 40;
   invPanel0.Width:=640;
   invPanel0.Height:=480;

   inventar0.FileName:='resources\books\book_d.avi';
   inventar0.Open;
   inventar0.Display:=invpanel0;
   inventar0.DisplayRect:=invPanel0.ClientRect;
   inventar0.play;

   pic3.book3opened:=true;
  end
else
 if (pic2.pages=0) and (pic3.book3opened=false) then
 begin
  invpic.Enabled:=false;
  Bookplay('resources\books\book_a.avi');
 end
else
 if pic2.pages=6 then
 begin
  invpic.Enabled:=false;
  Bookplay('resources\books\book_b.avi');
 end;
end;

procedure Tpic1.fwpageClick(Sender: TObject);
begin
 if pic2.pages=1 then
  begin
   PageSound;
   pic2.pages:=2;
   book_a.Picture.LoadFromFile('resources\books\2_030.jpeg');
  end
else
  if pic2.pages=2 then
   begin
    PageSound;
    pic2.pages:=3;
    book_a.Picture.LoadFromFile('resources\books\2_031.jpeg');
   end
else
  if pic2.pages=3 then
   begin
    PageSound;
    pic2.pages:=4;
    book_a.Picture.LoadFromFile('resources\books\2_032.jpeg');
   end
else
 if pic2.pages=4 then
   begin
    PageSound;
    pic2.pages:=5;
    book_a.Picture.LoadFromFile('resources\books\2_033.jpeg');
   end
else
 if pic2.pages=7 then
   begin
    PageSound;
    pic2.pages:=8;
    book_a.Picture.LoadFromFile('resources\books\2_053.jpeg');
   end
else
 if pic2.pages=8 then
   begin
    PageSound;
    pic2.pages:=9;
    book_a.Picture.LoadFromFile('resources\books\2_054.jpeg');
   end
end;

procedure Tpic1.bwpageClick(Sender: TObject);
begin
  if pic2.pages=2 then
   begin
    PageSound;
    pic2.pages:=1;
    book_a.Picture.LoadFromFile('resources\books\2_029.jpeg');
   end
else
  if pic2.pages=3 then
   begin
    PageSound;
    pic2.pages:=2;
    book_a.Picture.LoadFromFile('resources\books\2_030.jpeg');
   end
else
 if pic2.pages=4 then
   begin
    PageSound;
    pic2.pages:=3;
    book_a.Picture.LoadFromFile('resources\books\2_031.jpeg');
   end
else
 if pic2.pages=5 then
   begin
    PageSound;
    pic2.pages:=4;
    book_a.Picture.LoadFromFile('resources\books\2_032.jpeg');
   end
else
 if pic2.pages=9 then
   begin
    PageSound;
    pic2.pages:=8;
    book_a.Picture.LoadFromFile('resources\books\2_053.jpeg');
   end
else
 if pic2.pages=8 then
   begin
    PageSound;
    pic2.pages:=7;
    book_a.Picture.LoadFromFile('resources\books\2_052.jpeg');
   end
end;

end.
