unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Timer1: TTimer;
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    MediaPlayer1: TMediaPlayer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
   Form4: TForm4;
  fon3:tbitmap;
  m:tbitmap;
  x:integer;
  shagx:integer;
implementation

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
begin
shagx:=20;
fon3:=tbitmap.create;
m:=tbitmap.create;
fon3.loadfromfile('fon3.bmp');
m.loadfromfile('m.bmp');
m.Transparent:=true;
image1.Canvas.Draw(0,0,fon3);
image1.Canvas.Draw(x,300,m);
end;

procedure TForm4.Timer1Timer(Sender: TObject);
begin
 x:=x+shagx;
if x>500 then shagx:=shagx-1;
if x<0 then shagx:=shagx-1;
image1.Canvas.Draw(0,0,fon3);
image1.Canvas.Draw(x,300,m);
end;

procedure TForm4.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=37 then shagx:=-15;
if key=39 then shagx:=15;
end;

procedure TForm4.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then begin
mediaplayer1.filename:=opendialog1.FileName;
mediaplayer1.Open;
end;

end;
end.
