Добавил:
Kaz
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:АСОИ, Delphi, много вариантов 2 сем / 1классы / Машинка с фарами / MyRec
.pas unit MyRec;
interface
Uses Graphics;
Type TRec=class(Tobject)
x,y,r: integer;
color: Tcolor;
canvas: Tcanvas;
constructor create(x0,y0,r0: integer; color0: Tcolor; canvas0: Tcanvas);
procedure move(dx,dy: integer);virtual;
procedure show(Col1,Col2:Tcolor); virtual;
end;
implementation
Constructor TRec.Create;
begin
inherited Create;
X:=x0;
y:=y0;
r:=r0;
Color:=Color0;
Canvas:=Canvas0;
end;
Procedure TRec.Show(Col1,Col2:Tcolor);
var
x1,y1:word;
begin
With Canvas do begin
pen.Color:=Col1;
Brush.Color:=Col2;
x1:=x-50;
y1:=y-100;
{Moveto(x1,y1);}
Rectangle(X1,Y1-10,X1+100,Y1+210);
{Lineto(x1+100,y1);
lineto(x1+100,Y1+200);
Lineto(x1,y1+200);
Lineto(x1,y1);}
end;
end;
Procedure TRec.move(dx,dy: integer);
begin
Show(clWhite,clWhite);
X:=X+dx;
Y:=y+dY;
Show(clBlack,Color);
end;
end.
interface
Uses Graphics;
Type TRec=class(Tobject)
x,y,r: integer;
color: Tcolor;
canvas: Tcanvas;
constructor create(x0,y0,r0: integer; color0: Tcolor; canvas0: Tcanvas);
procedure move(dx,dy: integer);virtual;
procedure show(Col1,Col2:Tcolor); virtual;
end;
implementation
Constructor TRec.Create;
begin
inherited Create;
X:=x0;
y:=y0;
r:=r0;
Color:=Color0;
Canvas:=Canvas0;
end;
Procedure TRec.Show(Col1,Col2:Tcolor);
var
x1,y1:word;
begin
With Canvas do begin
pen.Color:=Col1;
Brush.Color:=Col2;
x1:=x-50;
y1:=y-100;
{Moveto(x1,y1);}
Rectangle(X1,Y1-10,X1+100,Y1+210);
{Lineto(x1+100,y1);
lineto(x1+100,Y1+200);
Lineto(x1,y1+200);
Lineto(x1,y1);}
end;
end;
Procedure TRec.move(dx,dy: integer);
begin
Show(clWhite,clWhite);
X:=X+dx;
Y:=y+dY;
Show(clBlack,Color);
end;
end.