unit Tischtennis;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 =
class(TForm)
tmrBall: TTimer;
tmrBall2: TTimer;
Shape1: TShape;
Wand: TShape;
Shape5: TShape;
Shape3: TShape;
Shape4: TShape;
Schlaeger: TShape;
Shape2: TShape;
Ball: TShape;
procedure tmrBallTimer(Sender: TObject);
procedure tmrBall2Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
Richtung, RWeite: integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Tempo: integer;
implementation
{$R *.dfm}
procedure TForm1.tmrBallTimer(Sender: TObject);
begin
if Ball.Top + Ball.Height >= Schlaeger.Top
then
begin
tmrBall.Enabled := false;
tmrBall2.Enabled := true
end
else
Ball.Top := Ball.Top + Tempo;
end;
procedure TForm1.tmrBall2Timer(Sender: TObject);
begin
Randomize;
if Richtung = 0
then
begin
Richtung := Random(2);
RWeite := Random(5);
end;
Ball.Top := Ball.Top - Tempo;
if Ball.Top <= Wand.Top + Wand.Height
then
tmrBall2.Enabled := false
else
if Richtung = 0
then
ball.Left := ball.Left - Rweite
else
ball.Left := ball.Left + Rweite;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Richtung := 0;
Rweite := 0;
Tempo := 20;
end;
end.