Скачиваний:
10
Добавлен:
15.06.2014
Размер:
1.63 Кб
Скачать
unit Unit2;

interface
uses Graphics;
var ColrBack:Tcolor;
Type
Tpr=class
Canvas: Tcanvas;
ColrLine: TColor;
x1,y1,x2,y2: word;
Procedure Ris; virtual; abstract;
Procedure Draw(bl:boolean);
procedure MoveTo(dx,dy:integer);
end;

Tsoldat=class(Tpr)
ches: boolean;
Constructor Create(x01,y01,x02,y02:word; colrLine0:Tcolor; canvas0:Tcanvas);
procedure Ris; override;
procedure odtches;
end;


implementation
Procedure Tpr.Draw;
begin
with canvas do begin
if bl then
begin
pen.color:=clblack; brush.color:=colrLine;
end
else begin
pen.color:=colrBack; brush.color:=colrBack;
end;
Ris;
end; end;

Procedure Tpr.MoveTo;
begin
draw(false);
x1:=x1+dx;
x2:=x2+dx;
y1:=y1+dy;
y2:=y2+dy;
Draw(true);
end;

Constructor Tsoldat.Create;
begin
canvas:=canvas0;
ColrLine:=ColrLine0;
x1:=x01;
x2:=x02;
y1:=y01;
y2:=y02;
ches:=false;
Ris;
end;

Procedure Tsoldat.Ris;
begin
Canvas.Rectangle(x1,y1,x2,y2); //telo
Canvas.Rectangle(x2,y1+5,x2+15,y1+abs(y2-y1)div 2); //l ruka
if ches then Canvas.Rectangle(x1-15,y1+5,x1,y1-abs(y2-y1)div 2)
else Canvas.Rectangle(x1-15,y1+5,x1,y1+abs(y2-y1)div 2); //p ruka
Canvas.Rectangle(x2-abs(x2-x1) div 3 -5,y2,x2-5,y2+30); //l noga
Canvas.Rectangle(x1+5,y2,x1+abs(x2-x1)div 3 +5,y2+30); //p noga
Canvas.Ellipse(x1+(x2-x1)div 4,y1-(x2-x1)div 2, x2-abs(x2-x1)div 4,y1); //golova
end;

Procedure Tsoldat.odtches;
begin
draw(false);
if ches then ches:=false else ches:=true;
Draw(true);
end;

end.
Соседние файлы в папке солдатик
  • #
    15.06.20142.37 Кб10Unit1.dfm
  • #
    15.06.20142.78 Кб10Unit1.pas
  • #
    15.06.20142.37 Кб10Unit1.~dfm
  • #
    15.06.20142.79 Кб11Unit1.~pas
  • #
    15.06.20142.79 Кб10Unit2.dcu
  • #
    15.06.20141.63 Кб10Unit2.pas
  • #
    15.06.20141.62 Кб10Unit2.~pas