unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, MPlayer, jpeg, mmsystem;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Timer2: TTimer;
    Player: TMediaPlayer;
    Image1: TImage;
    Image7: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Timer3: TTimer;
    Image6: TImage;
    Timer4: TTimer;
    Image8: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  gl_time, alpha, pos_x, pos_y: Integer;
  Form1: TForm1;
  fs: boolean;



implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
sndPlaySound('start.wav', SND_SYNC);

 pos_x:=160;
 pos_y:=16;

 alpha:=0;
 gl_time:=0;
 Player.FileName:='funny.wav';
 Player.Open();
 Player.Play();
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 gl_time:=gl_time+1;
 Caption:='TIPA OSEN Project ['+IntToStr(gl_time)+'/XZ..]';
 if(gl_time<260) then
 begin
  fs:=not fs;
  Image8.Visible:=fs;
 end
 else Image8.Visible:=false;

 if(gl_time=800) then Image6.Visible:=true;
 if(gl_time=1000) then Image6.Picture.LoadFromFile('2.bmp');
 if(gl_time=1200) then Image6.Picture.LoadFromFile('3.bmp');
 if(gl_time=1400) then Image6.Picture.LoadFromFile('4.bmp');
 if(gl_time=1600) then Image6.Picture.LoadFromFile('5.bmp');
 if(gl_time=1800) then Image6.Picture.LoadFromFile('6.bmp');
 if(gl_time=2000) then
 begin
  Image6.Picture.LoadFromFile('7.bmp');
  Timer4.Enabled:=true;
 end;
 if(gl_time=2200) then
 begin
  Application.MessageBox('THE END', 'TIPA OSEN Project', 1);
  //ShowMessage('THE END!');
  Player.Stop();
  sndPlaySound('stop.wav', SND_SYNC);
  Close();
 end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
 alpha:=alpha+1;
 Form1.AlphaBlendValue:=alpha;
 Form1.Repaint();
 if(alpha=255) then
 begin
  Form1.Timer2.Enabled:=false;
  Form1.Timer3.Enabled:=true;
 end;

end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
 Image2.Top:=Image2.Top+random(10);
 Image3.Top:=Image3.Top+random(10);
 Image4.Top:=Image4.Top+random(10);
 Image5.Top:=Image5.Top+random(10);
 Image7.Top:=Image7.Top+random(10);
 Image2.Left:=Image2.Left+random(5)-3;
 Image3.Left:=Image3.Left+random(5)-4;
 Image4.Left:=Image4.Left+random(5)-2;
 Image5.Left:=Image5.Left+random(5)-1;
 Image7.Left:=Image7.Left+random(5)-2;
end;

procedure TForm1.Timer4Timer(Sender: TObject);
begin
 if(pos_x<250) then pos_x:=pos_x+1
 else pos_x:=pos_x-1;
 if(pos_y<100) then pos_y:=pos_y+1
 else pos_y:=pos_y-1;

 Image6.Left:=pos_x;
 Image6.Top:=pos_y;
end;

end.
