unit Pong;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure FormKeyPress(Sender: TObject;
var Key: Char);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
dicke, x, y: integer;
implementation
{$R *.dfm}
procedure TForm1.FormKeyPress(Sender: TObject;
var Key: Char);
begin
dicke := 20;
if key = '
s'
then
begin
form1.Refresh;
y := y+5;
canvas.brush.color := clnavy;
canvas.ellipse (x,y,x+dicke,y+dicke);
canvas.MoveTo(50,0);
canvas.lineto(50,350);
canvas.MoveTo(50,400);
canvas.lineto(50,500);
label1.Caption := inttostr(x);
label2.caption := inttostr(y);
end;
if key = '
d'
then
begin
form1.Refresh;
x := x+5;
canvas.brush.color := clnavy;
canvas.ellipse (x,y,x+dicke,y+dicke);
canvas.MoveTo(50,0);
canvas.lineto(50,350);
canvas.MoveTo(50,400);
canvas.lineto(50,500);
label1.Caption := inttostr(x);
label2.caption := inttostr(y);
if (x > 30)
and (x < 50)
then
end;
if key = '
a'
then
begin
form1.Refresh;
x := x-5;
canvas.brush.color := clnavy;
canvas.ellipse (x,y,x+dicke,y+dicke);
canvas.MoveTo(50,0);
canvas.lineto(50,350);
canvas.MoveTo(50,400);
canvas.lineto(50,500);
label1.Caption := inttostr(x);
label2.caption := inttostr(y);
end;
if key = '
w'
then
begin
form1.Refresh;
y := y-5;
canvas.brush.color := clnavy;
canvas.ellipse (x,y,x+dicke,y+dicke);
canvas.MoveTo(50,0);
canvas.lineto(50,350);
canvas.MoveTo(50,400);
canvas.lineto(50,500);
label1.Caption := inttostr(x);
label2.caption := inttostr(y);
end
end;
end.