unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
TMann =
class
xpos,xend,xrich,xchange : integer ;
constructor create(Mstart , Mende, Richtung :integer ) ;
procedure norm ;
procedure laufen ;
end;
var
Form1: TForm1;
Mann : TMann ;
i : integer ;
implementation
{$R *.dfm}
procedure TMann.Norm ;
begin
Form1.Canvas.Ellipse(xpos-10,510,xpos+10,530);
Form1.Canvas.moveto(xpos,530);
Form1.canvas.LineTo(xpos,560);
end ;
constructor TMann.create (Mstart , Mende , Richtung :integer ) ;
begin
xpos := Mstart ; xend := Mende ; xrich := Richtung ;
end;
procedure TMann.laufen ;
begin
randomize ;
if xpos > xend
then xchange := xpos - xend ;
if xpos < xend
then xchange := xend - xpos ;
for i := 0
to xchange
do
begin
//Normale Position!
xpos := xpos + 9*xrich ;
sleep(100) ;
Form1.Refresh ;
Norm ;
Form1.Canvas.MoveTo(xpos,560);
Form1.canvas.LineTo(xpos+12*xrich+Random(4)*xrich,600);
Form1.Canvas.MoveTo(xpos,560);
Form1.canvas.LineTo(xpos-12*xrich+Random(4)*xrich,600);
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos+10*xrich,565);
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos-10*xrich,565);
//Rechterarm1
xpos := xpos + 9*xrich ;
sleep(100) ;
Form1.Refresh ;
Norm ;
Form1.Canvas.MoveTo(xpos,560);
Form1.canvas.LineTo(xpos-12*xrich,600);
Form1.Canvas.moveto(xpos,560) ;
Form1.Canvas.LineTo(xpos+12*xrich,578);
Form1.canvas.MoveTo(xpos+12*xrich,578);
Form1.canvas.LineTo(xpos+Random(3)*xrich,600+Random(3));
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos+6*xrich,552);
Form1.canvas.MoveTo(xpos+6*xrich,552);
Form1.canvas.LineTo(xpos+16*xrich,549);
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos-13*xrich,565);
//Rechterarm2
xpos := xpos + 9*xrich ;
sleep(100) ;
Form1.Refresh ;
Norm ;
Form1.Canvas.MoveTo(xpos,560);
Form1.canvas.LineTo(xpos+12*xrich+Random(3)*xrich,600+Random(3));
Form1.Canvas.MoveTo(xpos,560);
Form1.canvas.LineTo(xpos-10*xrich,578);
Form1.Canvas.MoveTo(xpos-10*xrich,578);
Form1.canvas.LineTo(xpos-28*xrich+Random(3)*xrich,588+Random(3));
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos+10*xrich,565);
Form1.Canvas.moveto(xpos,540);
Form1.canvas.LineTo(xpos-8*xrich,552);
Form1.canvas.MoveTo(xpos-8*xrich,552);
Form1.canvas.LineTo(xpos-12*xrich,555);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Mann := TMann.create(800,800-29,-1);
Mann.laufen ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Mann := TMann.create(0,0,0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Mann := TMann.create(0,29,1);
Mann.laufen ;
end;
end.