unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
jpeg, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Image2: TImage;
Button1: TButton;
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen}
public
{ Public-Deklarationen}
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
case Key
of
VK_UP:
begin if (image2.Canvas.pixels[image1.left-3,image1.top -3 ]
in [clblack])
or (image2.Canvas.pixels[image1.left+53,image1.top -3 ]
in [clblack])
then
Image1.top:=image1.top+1
else
image1.top:=image1.top-1;
Key :=0;
end;
VK_DOWN:
begin if (image2.Canvas.pixels[image1.left+53,image1.top +53 ]
in [clblack])
or (image2.Canvas.pixels[image1.left-3,image1.top +53 ]
in [clblack])
then
Image1.top:=image1.top-1
else
image1.top:=image1.top+1;
Key :=0;
end;
VK_LEFT:
begin if (image2.Canvas.pixels[image1.left-3,image1.top -3 ]
in [clblack])
or (image2.Canvas.pixels[image1.left-3,image1.top +53 ]
in [clblack])
then
Image1.left:=image1.left+1
else
image1.left:=image1.left-1;
Key :=0;
end;
VK_RIGHT:
begin if (image2.Canvas.pixels[image1.left+53,image1.top +53 ]
in [clblack])
or (image2.Canvas.pixels[image1.left+55,image1.top -3 ]
in [clblack])
then
Image1.left:=image1.left-1
else
image1.left:=image1.left+1;
Key :=0;
end;
end;
button1.visible:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.visible:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage('
Hallo');
button1.visible:=false;
end;
end.