unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TSpielfeld =
class(TForm)
Bild: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;
TBall =
class x,y,vx,vy,r : integer;
farbe: tcolor;
procedure bewegdich;
procedure zeigdich;
procedure init(fneu:tcolor; xneu,yneu,vxneu,vyneu,rneu:integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Spielfeld: TSpielfeld;
Ball:TBall;
x1,x2,y1,y2,t:integer;
implementation
procedure tball.init(fneu:tcolor;xneu,yneu,vxneu,vyneu,rneu:integer);
begin
farbe:=fneu;
x:=xneu;
y:=yneu;
vx:=vxneu;
vy:=vyneu;
r:=rneu;
end;
procedure tball.zeigdich;
begin
Spielfeld.Bild.Canvas.Brush.Color:=farbe;
Spielfeld.Bild.Canvas.Ellipse(x1,y1,x2,y2);
end;
procedure tball.bewegdich;
begin
x:=x+vx;
y:=y+vy;
x1:=x-r;
x2:=x+r;
y1:=y-r;
y2:=y+r;
end;
procedure TSpielfeld.Timer1Timer(Sender: TObject);
begin
ball.zeigdich;
ball.bewegdich;
ball.zeigdich;
end;
procedure TSpielfeld.FormCreate(Sender: TObject);
begin
bild.Canvas.Brush.Color:=clwhite;
bild.Canvas.Pen.Width:=2;
bild.Canvas.Brush.Style:=bssolid;
bild.Canvas.Pen.Mode:=pmNOTXOR;
ball.init(clred,100,200,-4,3,20);
ball.zeigdich;
end;
end.