unit VirPoint; interface uses Graphics, Graph, Location; type //****************************************************************************** // Bod obsahujici virtualni metody //****************************************************************************** TVirPoint = class (TLocation) protected DirX,DirY : Integer; public constructor Create (InitX, InitY: Integer); procedure MoveTo(NewX, NewY: Integer); procedure Move; virtual; procedure Draw; virtual; end; implementation //****************************************************************************** // //****************************************************************************** constructor TVirPoint.Create(InitX, InitY: Integer); begin inherited Create(InitX, InitY); DirX:=random(6)-2; DirY:=random(6)-2; end; //****************************************************************************** // //****************************************************************************** procedure TVirPoint.MoveTo (NewX, NewY: Integer); begin X:=NewX; Y:=NewY; end; //****************************************************************************** // //****************************************************************************** procedure TVirPoint.Move; begin X:=X+DirX; if X>Graph.Canvas.ClipRect.Right then DirX:=-DirX; if X<0 then DirX:=-DirX; Y:=Y+DirY; if Y>Graph.Canvas.ClipRect.Bottom then DirY:=-DirY; if Y<0 then DirY:=-DirY; end; //****************************************************************************** // //****************************************************************************** procedure TVirPoint.Draw; begin Graph.Canvas.Pixels[X ,Y ]:=$0000ff; Graph.Canvas.Pixels[X ,Y+1]:=$0000ff; Graph.Canvas.Pixels[X+1,Y ]:=$0000ff; Graph.Canvas.Pixels[X+1,Y+1]:=$0000ff; end; end.