unit U_Main;
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TRichtung = (links, rechts, undefiniert);
TDemo_Form =
class(TForm)
Button1: TButton;
Ball: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Richtung: TRichtung;
RWeite: Integer;
public
{ Public-Deklarationen }
end;
var
Demo_Form: TDemo_Form;
implementation
{$R *.dfm}
procedure TDemo_Form.FormCreate(Sender: TObject);
begin
Randomize;
RWeite := 0;
Richtung := undefiniert;
end;
procedure TDemo_Form.Button1Click(Sender: TObject);
begin
if Richtung = undefiniert
then
begin
Richtung := TRichtung(Random(2));
RWeite := Random(5);
end;
case Richtung
of
links: Ball.Left := Ball.Left - Rweite;
rechts: Ball.Left := Ball.Left + Rweite;
end;
Ball.Top := Ball.Top - 10;
end;