unit Unit2;

interface

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

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

var
  Form2: TForm2;
  fon:tbitmap;
  ez:tbitmap;
  x:integer;
  shagx:integer;
  fon2:tbitmap;
  ka:tbitmap;
implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
shagx:=20;
fon:=tbitmap.create;
ez:=tbitmap.create;
fon.loadfromfile('fon.bmp');
ez.loadfromfile('ez.bmp');
ez.Transparent:=true;
image1.Canvas.Draw(0,0,fon);
image1.Canvas.Draw(x,50,ez);
end;

procedure TForm2.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,fon);
image1.Canvas.Draw(x,50,ez);
end;

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


end.
