unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Panel: TPanel;
Background: TImage;
SBall: TImage;
SPlayer: TImage;
Infopanel: TPanel;
PMenu: TPanel;
LScore: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure PMenuClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
PosX, PosY, X, Y: Integer;
implementation
uses Unit2, Unit4;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
PosX:=200;
PosY:=208;
X:=2;
Y:=3;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
Var
Overlay: Trect;
begin
//Bewegung
PosX:=PosX+X;
PosY:=PosY+Y;
//Seitenwände
If PosX>Panel.width - SBall.width then
X:=-X;
If PosX< 0 then
X:=-X;
//Obere und Untere Wand
If PosY>Panel.height - SBall.height then
Y:=-Y;
If PosY< 0 then
Y:=-Y;
SBall.left:=round(PosX);
SBall.Top:=round(posY);
//Ball trifft Schläger
If intersectrect (Overlay, SPlayer.BoundsRect, SBall.BoundsRect) then
begin
X:=-X-random(2);
Y:=-Y-random(2);
end;
//Ball daneben
If SBall.height=Panel.height-SBall.height then
form4.show;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_ESCAPE then
halt;
if key = VK_Left then
SPlayer.left:= SPlayer.Left-13;
if key = VK_Right then
SPlayer.left:= SPlayer.left+13;
end;
procedure TForm1.PMenuClick(Sender: TObject);
begin
form1.close; form2.show
end;
end.