Einzelnen Beitrag anzeigen

Wolverine

Registriert seit: 30. Mai 2003
Ort: Düsseldorf (NRW)
109 Beiträge
 
Delphi 7 Enterprise
 
#4
  Alt 31. Mai 2003, 12:05
Ok.
Hier nun mal der Quellcode (ist etwas lang!!!)

Delphi-Quellcode:
  TAnimation = class(TImageSprite)
  public
    procedure DoMove(MoveCount: Integer); override;
    constructor Create(AParent: TSprite ); override;
    procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
  end;

  TGegenstand = class(TImageSprite)
  public
    constructor Create(AParent: TSprite ); override;
  end;

var
  Form1: TForm1;
  Animation: TAnimation;
  Gegen:tgegenstand;

implementation

constructor TGegenstand.Create(AParent: TSprite );
begin
  inherited Create(AParent);
  Image:=Form1.DXImageList1.Items.Find('Stein');
  Width := Image.Width;
  Height := Image. Height;
  Visible:=True;
end;

constructor TAnimation.Create(AParent: TSprite );
begin
  inherited Create(AParent);
  Image:=Form1.DXImageList1.Items.Find('1');
  Width :=Image.Width;
  Height :=Image. Height;
  Visible:=True;
end;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TAnimation.Create(DXSpriteEngine1.Engine) do
  begin
    x:=0;
    y:=0;
  end;
  with TGegenstand.Create(DXSpriteEngine1.Engine) do
  begin
    x:=40;
    y:=40;
  end;
end;

procedure TAnimation.DoCollision(Sprite: TSprite; var Done: Boolean);
begin
  if sprite is TGegenstand then
    begin
      beep;
      dead;
    end;
end;

procedure TAnimation.DoMove(MoveCount: Integer);
begin
  inherited DoMove(MoveCount); {Besonders wichtig !!!}
  If isUp in Form1.DXInput1.States Then
    Y := Y -1;
  If isDown in Form1.DXInput1.States
    Then Y := Y + 1;
  If isLeft in Form1.DXInput1.States Then
    X := X -1;
  If isRight in Form1.DXInput1.States Then
    X := X +1;
  AnimCount := 1; {Die Sachen kommen jetzt hier rein !!}
  AnimLooped := True;
  AnimSpeed := 20/1000;
  AnimStart := 0;

    Collision; {das muss ergänzt werden}
end;

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
  DXInput1.Update;
  DXSpriteEngine1.Move(1);
  DXDraw1.Surface.Fill(0);
  DXSpriteEngine1.Draw;
  DXDraw1.Flip;
end;

procedure TForm1.Beenden1Click(Sender: TObject);
begin
Application.Terminate;
end;

end.
Guido L.
The nice thing about Windows is - It does not just crash, it displays a dialog box and lets you press 'OK' first.
Guten Rutsch und Start ins neue Jahr 2005
  Mit Zitat antworten Zitat