unit Uball;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
Schlaeger: TShape;
Pgrenze: TPanel;
sball: TShape;
BStart: TButton;
procedure Timer1Timer(Sender: TObject);
procedure BStartClick(Sender: TObject);
procedure SchlaegerMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
bx: Integer;
by: integer;
implementation
{$R *.DFM}
procedure TForm1.BStartClick(Sender: TObject);
begin
bx:=5;
by:=5;
Timer1.enabled:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
sball.left:=sball.left+bx;
if sball.left < 0
then
begin
sball.left := 1;
bx := -bx;
end;
if sball.left > pgrenze.width - sball.width
then
begin
sball.left := pgrenze.width - sball.width;
bx := -bx;
end;
sball.top := sball.top+by;
if sball.top < 0
then
begin
sball.Top := 1;
by := -by;
end;
if sball.top > pgrenze.height - sball.height
then
begin
sball.top := pgrenze.height - sball.height;
by := -by;
end;
end;
procedure TForm1.SchlaegerMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Schlaeger.Left := X - Schlaeger.Width
div 2;
end;
end.