unit Spiel_01;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Image2: TImage;
ImageList1: TImageList;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure show (NR:integer);
public
{ Public-Deklarationen }
procedure KeyFirst(
var vorher: TWMKey);
message CM_DIALOGKEY;
procedure KeyLeft;
procedure KeyUp;
procedure KeyRight;
procedure KeyDown;
end;
const s=8;
var Form1: TForm1;
implementation
procedure TForm1.KeyFirst(
var vorher: TWMKey);
begin
case vorher.CharCode
of
VK_LEFT :
begin
KeyLeft;
show(4);
KeyLeft;
show(5);
KeyLeft;
show(6);
KeyLeft;
show(5);
KeyLeft;
show(4);
end;
VK_UP : KeyUp;
VK_RIGHT :
begin
Keyright;
show(1);
Keyright;
show(2);
Keyright;
show(3);
Keyright;
show(2);
Keyright;
show(1);
end;
VK_DOWN : KeyDown;
VK_ESCAPE: Close;
end;
show(0);
inherited;
end;
procedure TForm1.show(nr:integer);
begin
image2.picture:=nil;
imagelist1.getbitmap(Nr,form1.image2.picture.bitmap);
image2.Refresh;
sleep(100);
end;
//Bild nach Links verschieben
procedure TForm1.KeyLeft;
begin
Image2.Left := Image2.Left - s;
If Image2.Left < image1.left
then image2.left:= image2.left + s;
end;
//Bild nach Oben verschieben
procedure TForm1.KeyUp;
begin
Image2.Top := Image2.Top - s;
If Image2.top < image1.top
then image2.top:= image2.top + s;
end;
//Bild nach Rechts verschieben
procedure TForm1.KeyRight;
begin
Image2.Left := Image2.Left + s;
If (Image2.Left+Image2.Width) > (image1.left + image1.Width)
then image2.left:= image2.left - s;
end;
//Bild nach Unten verschieben
procedure TForm1.KeyDown;
begin
Image2.Top := Image2.Top + s;
If (Image2.top+Image2.height) > (image1.top + image1.height)
then image2.top:= image2.top - s;
end;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
// double.buffered:=true;
image2.top:=776;
image2.left:=24;
image28.Picture.Bitmap.TransparentColor:=clwhite;
image29.Picture.Bitmap.TransparentColor:=clwhite;
image30.Picture.Bitmap.TransparentColor:=clwhite;
image31.Picture.Bitmap.TransparentColor:=clwhite;
image32.Picture.Bitmap.TransparentColor:=clwhite;
end;
end.