unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, DXSprite, StdCtrls, DXClass;
type
TForm1 =
class(TForm)
DXDraw1: TDXDraw;
DXTimer1: TDXTimer;
DXImageList1: TDXImageList;
Blinks: TButton;
Brechts: TButton;
procedure FormActivate(Sender: TObject);
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
procedure BlinksClick(Sender: TObject);
procedure BrechtsClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
x: Integer = 0;
y: Integer = 0;
px: Integer = 320;
vx: Integer = 1;
vy: Integer = 1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
Form1.Cursor := crCross;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
if not DXDraw1.CanDraw
then
Exit;
x := x + vx;
y := y + vy;
if x <= 0
then
vx := vx * -1;
if x >= DXDraw1.Width - DXImageList1.Items[0].Width
then
vx := vx * -1;
if y <= 0
then
vy := vy * -1;
if y >= Form1.Height - DXImageList1.Items[0].Height
then
ShowMessage('
Sie haben verloren!');
DXImageList1.Items[1].draw(DXDraw1.Surface, 0, 0, 0);
DXImageList1.Items[0].Draw(DXdraw1.Surface, x, y, 0);
DXImageList1.Items[2].Draw(DXDraw1.Surface, px, 400, 0);
DXDraw1.Flip;
DXDraw1.Surface.Fill(0);
end;
procedure TForm1.BlinksClick(Sender: TObject);
begin
px := px - 10;
end;
procedure TForm1.BrechtsClick(Sender: TObject);
begin
px := px + 10;
end;
end.