unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, DXClass, DXSprite, StdCtrls, Buttons, DXInput;
type
TForm1 =
class(TForm)
DXDraw1: TDXDraw;
DXImageList1: TDXImageList;
DXTimer1: TDXTimer;
DXSpriteEngine1: TDXSpriteEngine;
DXInput1: TDXInput;
DXSpriteEngine2: TDXSpriteEngine;
procedure FormCreate(Sender: TObject);
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
// Für Animation
TAnimation =
class(TImageSprite)
Public
Procedure DoMove(MoveCount: Integer);
override;
Procedure DoCollision(Sprite: TSprite;
var Done: Boolean);
override;
end;
TGegenstand =
class(TImageSprite);
var
Form1: TForm1;
Animation: TAnimation;
Gegenstand: TGegenstand;
implementation
{$R *.dfm}
//////////////////////////////////////////////////////////////////////////////// FORM CREAT
procedure TForm1.FormCreate(Sender: TObject);
begin
Animation := TAnimation.Create(DXSpriteEngine1.Engine);
gegenstand := Tgegenstand.Create(DXSpriteEngine2.Engine);
with Animation
do
begin
Image := Form1.DXImageList1.Items.Find('
schiff');
X := 150;
Y := 150;
Width := Image.Width;
Height := Image.Height;
AnimCount := 3;
AnimLooped := True;
AnimSpeed :=1;
end;
with gegenstand
do
begin
Image := Form1.DXImageList1.Items.Find('
planet1');
X := 50;
Y := 50;
Width := Image.Width;
Height := Image.Height;
AnimCount := 4;
AnimLooped := True;
AnimSpeed :=1;
end;
end;
//////////////////////////////////////////////////////////////////////////////// Schiff
Procedure TAnimation.DoMove(MoveCount: Integer);
Begin
Inherited DoMove(MoveCount);
If IsUp
in Form1.DXInput1.States
Then Y:=Y-3;
If IsLeft
in form1.DXInput1.States
Then X:=X-3;
If IsDown
in form1.DXInput1.States
Then Y:=Y+3;
If IsRight
in form1.DXInput1.States
Then X:=X+3;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
DXInput1.Update;
DXSpriteEngine1.Move(1);
DXSpriteEngine2.Move(1);
DXDraw1.Surface.Fill(0);
DXSpriteEngine1.Draw;
DXSpriteEngine2.Draw;
DXDraw1.Flip;
end;
procedure TAnimation.DoCollision(Sprite: TSprite;
var Done: Boolean);
begin
if (sprite
is TGegenstand)
then showmessage('
Bumm');
end;
end.